C Test Questions)
C Test Questions)
PART I
sumdig(int n)
{
static int s=0;
int d;
if(n!=0)
{
d=n%10;
n=(n-d)/10;
s=s+d;
sumdig(n);
}
return(s); }
(a) 12 6 (b) 6 12 (c) 3 15 (d) error
(a) Compilation will only give a warning but will proceed to execute & will display
"fast"
(b) display "fast" on screen
(c) will give a compilation error.
(d) none of the above
14. What will be the value of i & j after the loop isexecuted?
for(i=0,j=0;i<5,j<25;i++,j++)
main()
{
int i,j;
i=10;
j=sizeof(++i);
printf("%d",i);
}
(a) 11 (b) 10 (c) 4 (d) compilation
error
----------
Part II
Subjective
1. Explain the following declaration. ( 5 marks)
int (*p)[10];
int *f();
int (*pf)();
int *p[10];
int *constp;
4. Write a brief note on ‘C’ compilation process with block diagram (2 marks).
5. Write a program to implement ternary operators. (2 marks).
6. Explain how to open a data file in different modes. Write a program to read
the contents from the file and print it to the monitor. (2 marks).
*************