Thursday 28 September 2017

Metric Conversion with structure

Q :Define two structures Metric and British that store distances. The Metric stores values in meters and centimeters and the British stores values in feet and inches. Write a program that reads both structure variables and add values contained in one variable of Metric to the contents of another variable of British. The program should display the result in both: equivalent centimeters and equivalent inches.


Solution : 



For solve this question you need to know metric measurement unit.

1 centimeter = 10 millimeters
1 meter = 100 centimeters = 1,000 millimeters

Wednesday 27 September 2017

Array pass to function


Array is a collection of similar data type which occupies continuous location on memory. Array’s name is a constant pointer which point first element of array. So when an array is passing to a function. Address of first element pass to function instead of value. If any change made inside of function body with array, then it affects actual value of passed array. Following program demonstrate this fact.

#include<stdio.h>
int update(int[]);
void main()
{
     int arr[5],i;
     for(i=0;i<5;i++)

Monday 25 September 2017

Compilation Process c Language



Q : How Compilation, Linking and Loading are related? Also explain the basic task of a Compiler, Linker and Loader?

Solution : 


First of all we need to understand relationship between compilation, linker and linker form following compilation steps.

Compilation Process C Language


Step 1

Sunday 24 September 2017

Sum of series using recursion

Q : Define recursion. Write a complete program to evaluate the given series using recursive function sum( ). Here n is user dependent.
1 + 2 + 3 +…+ n

Solution : 

As we C language is known as building block of functions. This means everything in c language is achieved through a function. In C language there is not any restriction to call a function you can call a function from anywhere No matter of scope.