1- what is the output of this program ? void main() { int const * p=5; printf("%d",++(*p)); } A- 5 B- Error C- Address of P D- 6 Correct answer is : Error because it is defined as constant and cant be changed 2- write the output of this program main() { int c[ ]={2,3,4,6,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf(" %d ",*c); ++q; } for(j=0;j<5;j++) { printf(" %d ",*p); ++p; } Output will be: 2222223465 3- which pointer can be used as a pointer to the following function : double multiply (double) ; A- double *p B- double *p(double) C- (double) *p (double) D-double (*p)(double) Correct answer is : D 4- what is the output of the following program main() { int i=3; switch(i) { default:printf("zero"); case 1: printf("one"); break; case 2:printf("two"); break; case 3: printf("three"); break; } } A- zero B- one C- two D- three The correct answer is D 5- what is the output of this program main() { int c=- -2; printf("c=%d",c); } A- 2 B- 1 C- -2 D- Generate Error Correct answer is A 6- this program generate an error write down which line(s) that cause this error? #include 1- main() 2- { 3- struct xx 4- { 5- int x=3; 6- char name[]="hello"; 7- }; 8- struct xx *s; 9- printf("%d",s->x); 10- printf("%s",s->name); 11- } Answer : lines 5,6 because we cant initialize the variables in the declaration of struct 7- write down the output of this program main() { int i; for(i=0;i<3;i++) { printing(); } } void printing() { auto int x =5; x=x+2; printf(“X=%d ”,x); } The answer is X=7 X=7 X=7 8- what is the output of the following program enum colors {BLACK,BLUE,GREEN} main() { printf("%d..%d..%d",BLACK,BLUE,GREEN); } Answer: 0..1..2 9- what is the output of this program main() { char *p; p="Hello"; printf("%c\n",*&*p); } Answer : H 10- What is the output of this program main() { int i=1,j=2; switch(i) { case 1: printf("GOOD"); break; case j: printf("BAD"); break; } } Answer : error case must take a constant value . 11- What is the output of this program main() { char not; not=!2; printf("%d",not); } Answer: 0 12- What is the output of this program #define FALSE -1 #define TRUE 1 #define NULL 0 main() { if(NULL) puts("NULL"); else if(FALSE) puts("TRUE"); else puts("FALSE"); } A - Error B – NULL C – TRUE D – FALSE Answer : C 13- What is the output of this program main() { int *ip; long *lp; ip=(int *)10; lp=(long *)20; ip++; lp++; printf("%d...%d",ip,lp); } Answer: 12…24 14- Which of the following are valid uses, when the array char box [10] is declared ? A- scanf(“%S”,&box); B- scanf(“%C”,&box[0]); C- scanf(“%S”,box); D- scanf(“%c”,*box[0]); Answer : B,C 15- What is the output of this program main() { int y; scanf("%d",&y); // input given is 2000 if( (y%4==0 && y%100 != 0) || y%100 == 0 ) printf("%d is a leap year"); else printf("%d is not a leap year"); } Answer : 2000 is a leap year 16- What is the output of this program main () { int x =5,y; y=function(x) } int function (int a) { if (a==1) return 1 ; else return a+function(a-1); } Answer : 15 17- What is the output of this program struct point { int x; int y; }; struct point origin,*pp; main() { origin.x=10; origin.y=15; pp=&origin; printf(“%d %d \n”,pp->x,(*pp).x); } Answer : 1010 18- What is the output of this program main() { int i=func(10); printf("%d\n",--i); } int func(int i) { return(i++); } Answer : 9 19- What is the output of this program main() { int *p; int *q; //long *r; p=(int *)890; q=(int *)920; p++; q++; printf("%d...%d...%d",p,q,q-p); } Answer : 892…922…15 20- What is the output of this program main() { int i =0;j=0; if(i && j++) printf("%d..%d",i++,j); printf("%d..%d,i,j); } Answer : 0..0 21- What is the output of this program main() { int a[10]; printf("%d",*a+1-*a+3); } Answer : 4 22- What is the output of this program func(int *a,int *b) { *a=*a+*b; *b=*a-*b; *a=*a-*b; } main() { int x=10,y=20; func(&x,&y); printf("x= %d y = %d\n",x,y); } Answer : x=20 y = 10 23- What is the output of this program main() { char *p = “ayqm”; printf(“%c”,++*(p++)); } Answer: b 24- How to access the element array[2][12] using pointers A- &array[2][12] B- *array[2]+*array[12] C- *(array[2]) +6 D- *(array[2]+6) Answer: D . 25- What is the output of this program main() { register int a=2; printf("Address of a = %d",&a); printf("Value of a = %d",a); } Answer : error because the register value don’t have address . 26- Is the following code is legal struct a { int x; struct a b; } A- YES B- NO Answer:No 27- What is the output of this program void main() { If (sizeof(struct test*)==sizeof(int *) && sizeof(int *) == sizeof(*float)) Printf(“Equal”) ; Else Printf (“Not Equal”); } Answer: Equal . 28- What is the output of this program void main() { int i=10, j=2; int *ip= &i, *jp = &j; int k = (*ip)/(*jp); printf(“%d”,k); } Answer: 5 29- What is the output of the following program main() { char a[4]="HELLO"; printf("%s",a); } Answer : Error size of the array is just 4 characters