This post contains 91-100 questions of c program. It will helpful to solve c aptitude questions, c quiz , c objective type questions etc in interview.
91-100 Questions
Q1:main() { char *str1="abcd"; char str2[]="abcd"; printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd")); } Answer: 2 5 5
Q2:
main() { int *j; { int i=10; j=&i; } printf("%d",*j); } Answer: 10
Q3:
void main() { int const * p=5; printf("%d",++(*p)); } Answer: Compiler error: Cannot modify a constant value.
Q4:
main() { char *p; int *q; long *r; p=q=r=0; p++; q++; r++; printf("%p...%p...%p",p,q,r); } Answer: 0001...0002...0004
Q5:
main(int argc, char **argv) { printf("enter the character"); getchar(); sum(argv[1],argv[2]); } sum(num1,num2) int num1,num2; { return num1+num2; } Answer: Compiler error.
Q6:
# include <stdio.h> int one_d[]={1,2,3}; main() { int *ptr; ptr=one_d; ptr+=3; printf("%d",*ptr); } Answer: garbage value
Q7:
# include<stdio.h> aaa() { printf("hi"); } bbb() { printf("hello"); } ccc(){ printf("bye"); } main() { int (*ptr[3])(); ptr[0]=aaa; ptr[1]=bbb; ptr[2]=ccc; ptr[2](); } Answer: bye
Q8:
In the following pgm add a stmt in the function fun such that the address of 'a' gets stored in 'j'. main(){ int * j; void fun(int **); fun(&j); } void fun(int **k) { int a =0; /* add a stmt here*/ } Answer: *k = &a
Q9:
main() { char *p; p="%d\n"; p++; p++; printf(p-2,300); } Answer: 300
Q10:
func(a,b) int a,b; { return( a= (a==b) ); } main() { int process(),func(); printf("The value of process is %d !\n ",process(func,3,6)); } process(pf,val1,val2) int (*pf) (); int val1,val2; { return((*pf) (val1,val2)); } Answer: The value if process is 0 !