C Kandar
C Kandar
C-KANDAR
1) Each question carries 1 mark
2) Time 30 minutes
3) Negative ½ mark for each wrong answer, 0 for unanswered ones.
main()
{
int i=-1,j=-1,k=0,l=2,m;
m=i++&&j++&&k++||l++;
printf("%d %d %d %d %d",i,j,k,l,m);
}
a) -1 -1 0 2 1
b) -1 -1 0 2 0
c) 00131
d) 00130
Q. 3. Which of the following is a valid function call (assuming the function exists)?
a) funct;
b) funct x, y;
c) funct();
d) int funct();
Q. 4. What is the final value of x when the code int x; for(x=0; x<10; x++) is run?
a) 10
b) 9
c) 0
d) 1
Q. 5. The statement
int **a;
a) is illegal
b) is legal but meaningless
c) is syntactically and semantically correct
d) none
a) prints 7
b) prints 8
c) prints 9
d) none
Q. 7. Which follows the case statement?
a) :
b) ;
c) -
d) A newline
void main()
{
putchar('M');
first();
putchar('m');
}
first(){ ???????}
second()
{
putchar('d');
}
a) typedef long a;
extern int a c;
b) typedef long a
extern a int c;
c) typedef long a;
extern a c;
Q. 12. What will be output if you will compile and execute the following c code?
void main()
{
int a=5;
float b;
printf("%d",sizeof(++a+b));
printf(" %d",a);
}
a) 2 6
b) 4 6
c) 2 5
d) 4 5
Q. 13. What will be output if you will compile and execute the following c code?
void main()
{
char c='0';
printf("%d %d",sizeof(c),sizeof('0'));
}
a) 1 1
b) 2 2
c) 1 2
d) 2 1
Q. 14. What will be output if you will compile and execute the following c code?
void main()
{
float f;
f=3/2;
printf("%f",f);
}
a) 1.5
b) 1.500000
c) 1.000000
d) Compiler error
a) diamond
b) rectangle
c) circle
d) arrow
Q. 16. In C programming, what does i equal at the end of the following piece (snippet) of
code?
i = 1;
i *= 5;
i += 3;
a) 8
b) 1
c) 5
d) 3
Q. 17. Which of the following statement is correct about the program given below:
#include<stdio.h>
void main()
{
int arr[3][3]={1,2,3,4};
printf(“%d\n”,*(*(*(a))));
}
Q. 18. Which files will get closed when the following program?
#include<stdio.h>
void main()
{
FILE *mad,*crazy,*fool;
mad=fopen(“crazy.c”,”r”);
crazy=fopen(“fool.c”,”w”);
fool=fopen(“mad.c”,”r”);
fclose(mad,crazy,fool);
}
a) mad.c c) fool.c
b) crazy.c d) all 3 files will get closed.
Q. 19. We want to round off x,a float , to an int value. What is the correct way to do so?
a) y= (int)(x+0.5);
b) y= int(x+0.5);
c) y= (int) x+0.5;
d) y= (int) ((int) x+0.5);
Q. 20. Are the three declarations same?
char **facebook;
char *facebook[];
char facebook[][];
Q. 21. How many times will the following loop be executed if the input data item is
01234 ?
while((c=getchar())!=0)
{
}
a) Infinite b) Never
c) Once d) 4 times.
a) 12 thelackswan b) 8 thlack
c) 8 theblack d) 9 the\black
Q. 25. Which of the following function can be used to find the first occurance of a given
string in another string?
a) strchr()
b) strstr()
c) strnset()
d) strspn()