This post contains 101-110 questions of c program. It will helpful to solve c aptitude questions, c quiz , c objective type questions etc in interview.
101-110 Questions
Q1:main() { char *p; printf("%d %d ",sizeof(*p),sizeof(p)); } Answer: 1 2
Q2:
main() { char string[]="Hello World"; display(string); } void display(char *string) { printf("%s",string); } Answer: Compiler Error : Type mismatch in redeclaration of function display
Q3:
#include<stdio.h> main() { char s[]={'a','b','c','\n','c','\0'}; char *p,*str,*str1; p=&s[3]; str=p; str1=s; printf("%d",++*p + ++*str1-32); } Answer: 77
Q4:
#include<stdio.h> main() { int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} }; int *p,*q; p=&a[2][2][2]; *q=***a; printf("%d----%d",*p,*q); } Answer: SomeGarbageValue---1
Q5:
puts(argv[0])prints a) the name of the source code file b) the number of command line arguments c) argv d)the name of the executable code file Answer:
Q6:
The addressoperator & , cannot act on a) R-values b) arithmetic expressions c) members of a structure d) local variables Answer:
Q7:
The argument used to print the number of command line arguments is a) printf("%d",argv); b) printf("%d",argv[0]); c) printf("%d",argc); d) none Answer:
Q8:
In command line arguments main() function takes ____ number of arguments a) 1 b) 2 c) 3 d) 4 Answer:
Q9:
#include<stdio.h> main() { struct xx { int x=3; char name[]="hello"; }; struct xx *s; printf("%d",s->x); printf("%s",s->name); } Answer: Compiler Error
Q10:
#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; } Answer: Compiler Error