Вы находитесь на странице: 1из 20

1. Which of the following is false for switch statement in C++? a.

It uses labels instead of blocks

b. we need to put break statement at the end of the group of statement of a condition c. d. we can put range for case such as case 1..3 None of above

ANS:C 2. In case of pass by reference

a. The values of those variables are passed to the function so that it can manipulate them b. The location of variable in memory is passed to the function so that it can use the same memory area for its processing c. The function declaration should contain ampersand (& declaration d. All of above in its type

ANS: B

3. What will be the output of the following arithmetic expression ? 5+3*2%10-8*6 a) -37 b) -42 c) -32 d) -28

ans:A

4. What will be the output of the following statement ? int a=10; printf("%d &i",a,10); a) error b) 10 c) 10 10 d) none of these

ANS:D

5. What will be the output of the following statement ? printf("%X%x%ci%x",11,10,'s',12); a) error b) basic c) Bas94c d) none of these

ANS:B

6. What will be the output of the following statements ? int a = 4, b = 7,c; c = a = = b; printf("%i",c); a) 0 b) error c) 1 d) garbage value

ANS:A

7. What will be the output of the following statement ? printf( 3 + "goodbye"); a) goodbye b) odbye c) bye d) dbye

ANS:(D)

8. What will be the output of the following statements ? int a = 5, b = 2, c = 10, i = a>b void main() { printf("hello"); main(); } a) 1 b) 2 c) infinite number of times d) none of these

ANS: C

9. What will be the output of the following program ? #include<stdio.h> void main() { int a = 2; switch(a) { case 1: printf("goodbye"); break; case 2: continue; case 3: printf("bye"); } } a) error b) goodbye c) bye d) byegoodbye

ans:A

10 . What will be the output of the following statements ?

int i = 1,j; j=i--- -2; printf("%d",j); a) error b) 2 c) 3 d) -3

ANS:C (3)

11. What will be the output of following program ? #include

main() { int x,y = 10; x = y * NULL; printf("%d",x); } a) error b) 0 c) 10 d) garbage value

ANS: (B). 0 12. What will be the output of the following statements ?

int i = 3; printf("%d%d",i,i++); a) 34 b) 43 c) 44 d) 33

(b):4,3

13. void main() {

int a=10,b=20; char x=1,y=0; if(a,b,x,y) { printf("EXAM"); } } What is the output? 1) 2) 3) 4) XAM is printed exam is printed Compiler Error Nothing is printed

ANS:4-> NOTHING IS PRINTED 14 What would be the output of the following program? #include main() { char str[]="S\065AB";

printf("\n%d", sizeof(str)); }

1) 2) 3) 4)

7 6 5 error

ans(2)

1. 15. Evaluate !(1 && !(0 || 1)) a. True b. False

c. Unevaluated table d. None of the above

Ans:a

16. Which of the following function sets first n characters of a string to a given character? A. strinit() C. strset() B. strnset() D. strcset()

ans :B 17. main( ) { printf ( "%c", "abcdefgh"[4] ) ; } A. e B.abcde

C.efgh D.Error

ANS:A

18. Find the output.

main( ) { printf ( "\n%d%d", sizeof ( 3 ), sizeof ( "3" ), sizeof ( 3 ) ) ; } A. 12 B.123 C.1234 D. Error

ANS:a

19. Find the output.

#include<stdio.h> #include<string.h> int main() {char str[] = "Programming"; printf("%s ",&str[2]);

printf("%s ",str); printf("%s ",&str); return(0); } 1. ogramming Programming Programming 2. ogramming Programming < Garbage Value > 3. Programming ogramming Programming 4. Program Compiled with Syntax Errors

ANS:1

20: char txt [20] = "Hello world!\0"; How many bytes are allocated by the definition above? A. 11 bytes
B. 12 bytes C.13 bytes D. 20 bytes

ANS:D

Вам также может понравиться