c questions
DESCRIPTION
c QuestionsTRANSCRIPT
C QUESTIONS
1. What will be output when you will execute following c code in turbo c++?
#include<stdio.h>int main(){ printf("%d\t",sizeof(6.5)); printf("%d\t",sizeof(90000)); printf("%d",sizeof('A'));
return 0;}(A) 4 2 1 (B) 8 2 1 (C) 4 4 1(D) 8 4 1 (E) 8 4 2
2. Consider on following declaring of enum. (i) enum cricket {Gambhir,Smith,Sehwag}c; (ii) enum cricket {Gambhir,Smith,Sehwag}; (iii) enum {Gambhir,Smith=-5,Sehwag}c; (iv) enum c {Gambhir,Smith,Sehwag};
A. Only (i) is correct declarationB. Only (i) and (ii) is correct declarationC. Only (i) and (iii) are correct declarationD. Only (i),(ii) and are correct declarationE. All four are correct declaration
3. What will be output when you will execute following c code in turbo c++?
#include<stdio.h>int main(){ signed x; unsigned y; x = 10 +- 10u + 10u +- 10; y = x; if(x==y) printf("%d %d",x,y); else if(x!=y) printf("%u %u",x,y);
return 0; }
(A) 0 0(B) 65536 -10 (C) 0 65536 (D) 65536 0
(E) Compilation error
4. What will be output when you will execute following c code in turbo c++? #include<stdio.h>int main(){ double num=5.2; int var=5; printf("%d\t",sizeof(!num)); printf("%d\t",sizeof(var=15/2)); printf("%d",var);
return 0; }
(A) 4 2 7
(B) 4 4 5
(C) 2 2 5
(D) 2 4 7
(E) 8 2 7
What will be output when you will execute following c code?
#include<stdio.h>int main(){ const int *p; int a=10; p=&a; printf("%d",*p);
return 0;}
(A) 0
(B) 10
(C) Garbage value
(D) Any memory address
(E)Error: Cannot modify const object
6. Consider on following declaration:(i) short i=10;(ii) static i=10;(iii) unsigned i=10;(iv) const i=10;
(A) Only (iv) is incorrect(B) Only (ii) and (iv) are incorrect(C) Only (ii),(iii) and (iv) are correct(D) Only (iii) is correct(E) All are correct declaration
7. What will be output when you will execute following c code?
#include<stdio.h>int main(){ int a= sizeof(signed) +sizeof(unsigned); int b=sizeof(const)+sizeof(volatile); printf("%d",a+++b);
return 0;}(A) 10 (B) 9 (C) 8(D) Error: Cannot find size of modifiers(E) Error: Undefined operator +++
8. What will be output when you will execute following c code? #include<stdio.h>int main(){ signed x,a; unsigned y,b; a=(signed)10u; b=(unsigned)-10; y = (signed)10u + (unsigned)-10; x = y; printf("%d %u\t",a,b); if(x==y) printf("%d %d",x,y); else if(x!=y) printf("%u %u",x,y);
return 0;}
(A) 10 -10 0 0
(B) 10 -10 65516 -10
(C) 10 -10 10 -10
(D) 10 65526 0 0
(E) Compilation error
9. What will be output when you will execute following c code?
#include<stdio.h>int main(){ volatile int a=11; printf("%d",a);
return 0;}
(A) 11
(B) Garbage
(C) -2
(D) We cannot predict
(E) Compilation error
10. What is the range of signed int data type in that compiler in which size of int is two byte?
(A) -255 to 255(B) -32767 to 32767(C) -32768 to 32768(D) -32767 to 32768(E) -32768 to 32767
11. What will be output when you will execute following c code?#include<stdio.h>const enum Alpha{ X, Y=5, Z}p=10; int main(){ enum Alpha a,b; a= X; b= Z; printf("%d",a+b-p);
return 0; }(A) -4 (B) -5 (C) 10 (D)11 (E) Error: Cannot modify constant object
12. What will be output when you will execute following c code?
#include<stdio.h>int main(){ char a=250; int expr; expr= a+ !a + ~a + ++a; printf("%d",expr);
return 0;}
(A) 249
(B) 250
(C) 0(D) -6(E) Compilation error
13. What will be output when you will execute following c code?
#include<stdio.h>int main(){ int a=-5; unsigned int b=-5u; if(a==b) printf("Avatar"); else printf("Alien");
return 0;}
(A) Avatar(B) Alien(C) Run time error(D) Error: Illegal assignment
(E) Error: Don’t compare signed no. with unsigned no.
14. Which of the following is not derived data type in c?
(A) Function(B) Pointer (C) Enumeration(D) Array(E) All are derived data type
15. What will be output when you will execute following c code?
#include<stdio.h>enum A{ x,y=5, enum B{ p=10,q }varp;}varx;int main(){ printf("%d %d",x,varp.q);
return 0;}
(A) 0 11(B) 5 10 (C) 4 11(D) 0 10(E) Compilation error
16. The keyword used to transfer control from a function back to the calling function is
A. switchB. gotoC. go backD. Return
17. What is the notation for following functions? 1. int f(int a, float b) { /* Some code */ }2. int f(a, b) int a; float b; { /* Some code */ }
A.
1. KR Notation 2. ANSI
Notation
B.
1. Pre ANSI C Notation
2. KR Notation
C.
1. ANSI Notation
2. KR Notation
D.
1. ANSI Notation
2. Pre ANSI Notation
18. How many times the program will print "abcdef" ?
#include<stdio.h>int main(){ printf("abcdef"); main(); return 0;}A. Infinite times B. 32767 timesC. 65535 times D. Till stack
overflows
19. will be the output of the program in 16 bit platform (Turbo C under DOS)?
#include<stdio.h> int main() { int fun(); int i; i = fun(); printf("%d\n", i); return 0; } int fun() { _AX = 1990; }
A. Garbage value B. 0 (Zero)
C. 1990 D. No output
20. What will be the output of the program? #include<stdio.h>void fun(int*, int*);int main(){ int i=5, j=2; fun(&i, &j); printf("%d, %d", i, j); return 0;}void fun(int *i, int *j){ *i = *i**i; *j = *j**j;}A.5, 2 B.10, 4 C.2, 5 D.25, 4
21. What will be the output of the program? #include<stdio.h>int reverse(int); int main(){ int no=5; reverse(no); return 0;}int reverse(int no){ if(no == 0) return 0; else printf("%d,", no); reverse (no--);}
A. Print 5, 4, 3, 2, 1 B. Print 1, 2, 3, 4, 5C. Print 5, 4, 3, 2, 1, 0 D. Infinite loop
23. What will be the output of the program? #include<stdio.h>int main(){ int a[5] = {5, 1, 15, 20, 25}; int i, j, m; i = ++a[1]; j = a[1]++; m = a[i++]; printf("%d, %d, %d", i, j, m); return 0;}
A. 2, 1, 15 B. 1, 2, 5C. 3, 2, 15 D. 2, 3, 20
24. What will be the output of the program ? #include<stdio.h>int main(){ void fun(int, int[]); int arr[] = {1, 2, 3, 4}; int i; fun(4, arr); for(i=0; i<4; i++) printf("%d,", arr[i]); return 0;}void fun(int n, int arr[]){ int *p=0; int i=0; while(i++ < n) p = &arr[i]; *p=0;}
A. 2, 3, 4, 5 B. 1, 2, 3, 4C. 0, 1, 2, 3 D. 3, 2, 1 0
24. What will be the output of the program ? #include<stdio.h>void fun(int **p);int main(){ int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 8, 7, 8, 9, 0}; int *ptr; ptr = &a[0][0]; fun(&ptr); return 0;}void fun(int **p){ printf("%d\n", **p);A.1 B.2 C.3 D.4
26. What will be output of following program? #include<stdio.h>int main(){ int a = 320; char *ptr; ptr =( char *)&a; printf("%d ",*ptr); return 0; }(A) 2 (B) 320 (C) 64(D) Compilation error (E) None of above
26. What will be output of following program?#include<stdio.h> int main() { int i = 3; int *j; int **k; j=&i; k=&j; printf("%u %u %d ",k,*k,**k);
return 0; }(A) Address, Address, 3 (B) Address, 3, 3(C) 3, 3, 3 (D) Compilation error(E) None of above
27. What will be output of following program? #include<stdio.h> int main() { char far *p =(char far *)0x55550005; char far *q =(char far *)0x53332225; *p = 80; (*p)++; printf("%d",*q); return 0; }(A) 80 (B) 81 (C) 82(D) Compilation error (E) None of above
28. What will be output of following program? #include<stdio.h> #include<string.h> int main() {char *ptr1 = NULL;char *ptr2 = 0;strcpy(ptr1," c");strcpy(ptr2,"questions");printf("\n%s %s",ptr1,ptr2);return 0; }(A) c questions (B) c (null) (C) (null) (null)(D) Compilation error (E) None of above
29. What will be output of following program? #include<stdio.h> #include<string.h> int main() {register a = 25;int far *p;p=&a;printf("%d ",*p);return 0; }(A) 25 (B) 4 (C) Address(D) Compilation error (E) None of above
30. What will be output of following program? #include<stdio.h> int main() {int a = 10;void *p = &a;int *ptr = p;printf("%u",*ptr);return 0; }(A) 10 (B) Address (C) 2(D) Compilation error (E) None of above