Gujarat Technological University: Instructions
Gujarat Technological University: Instructions
Gujarat Technological University: Instructions
______
Q.1 (a) What are the major components of C program? State significance of the name 03
‘main’.
(b) Write a note on process of compilation. 03
(c) Do as directed : 08
(i) State what will be the output of following code :
void main()
{ int i,j,k,a ;
i=2; j=5 ;
k= (++i)*(j--);
a = k+ (i++) – (++j);
printf( “%d %d “,k,a);
}
(ii) Write an algorithm to read a value of N and generate sum of first N odd
natural numbers.
(iii) Compare use of if-else statement with the use of ? : operator. When
will you prefer to use ? : operator? Why ?
(iv) Explain use of escape sequence with an example.
Q.2 (a) What is purpose of the getchar() and putchar() functions? How they are used 07
within a C program? Compare them with gets() and puts() functions
respectively for string handling operations.
(b) What is meant by looping? Describe two different forms of looping. Explain 07
use of each form using appropriate example.
OR
(b) Compare use of switch statement with the use of nested if-else statement. 07
Which is more convenient? Why? Also explain importance of break statement
with an example.
Q.3 (a) What is an array? Explain the procedure to initialize one-dimensional and two 04
dimensional array.
(b) Write a C program to read a matrix and find out the maximum element and its 04
position in the matrix.
(c) What is a function? State advantages of using functions. Write a program using 06
function to calculate sum of digits of a given positive integer number.
OR
Q.3 (a) In what way does an array differ from an ordinary variable? Explain internal 04
representation of arrays in C.
1
(b) Write a C program to count number of characters in a given string. 04
(c) Write a brief note on following : 06
(i) Recursive functions and their applications.
(ii) Advantages of command line arguments.
(iii) Local vs. global variables.
Q.4 (a) What is a pointer? Why are they important? Explain usage of NULL pointer. 04
(b) State and explain, what following statements will do ? Why ? 04
(i) int a, *b = &a;
(ii) char *s;
(iii) a = (float *) &x;
(iv) double (*a)[12];
(c) What is a structure? Differentiate between structure and union. Declare and 06
initialize a structure array to hold birthdates of three persons. Assume that
value of day, month and year are of type integer.
OR
Q.4 (a) Explain usage of malloc() and realloc() functions. 04
(b) State and explain with reasons what will be output if any for following 04
statements?
(i) void main()
{ int x= 0, *p=0;
x++ ; p++;
printf(“%d and %d “ , x,p);
}
(ii) void main()
{ int a [] = {1,2,3,4,5,6,7,8,9};
int *p = a+1;
int *q = a+6;
printf(“\n %d”, q-p);
}