C Interview Questions 31-40

This post contains 31-40 questions of c program. It will helpful to solve c aptitude questions, c quiz , c objective type questions etc in interview.

31-40 Questions

Q1:
The expression 4+6/3*2-2+7%3 evaluates to 
a) 3 
b) 4 
c) 6 
d) 7

Answer:


Q2:
Any C program 
a) must contain at least one function 
b) need not contain ant function 
c) needs input data 
d) none of the above

Answer:

Q3:
Using goto inside for loop is equivalent to using 
a) continue 
b) break 
c) return 
d)none of the above
Answer:


Q4:
The program fragment 
int a=5,b=2; 
printf("%d",a+++++b); 

a) prints 7 
b)prints 8 
c) prints 9 
d)none of the above
Answer:


Q5:
printf("ab" , "cd" , "ef"); prints 
a) ab 
b) abcdef 
c) abcdef, followed by garbage value 
d) none of the above
Answer:


Q6:
Consider the following program segment. i=6720; j=4;
while((i%j)==0)
{
i=i/j;
j=j+1;
}
On termination j will have the value
a) 4 
b) 8 
c) 9 
d) 6720
Answer:

Q7:
main()
{
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}
Answer:
mmmm
aaaa
nnnn

Q8:
main()
{
extern int i;
i=20;
printf("%d",i);
}
Answer:
Linker Error : Undefined symbol '_i'

Q9:
#define int char
main()
{
int i=65;
printf("sizeof(i)=%d",sizeof(i));
}
Answer:
sizeof(i)=1


Q10:
#define square(x) x*x
main()
{
int i;
i = 64/square(4);
printf("%d",i);
}
Answer:
64

Comments are closed.