Solved MCQ on C Programming Language set-5


1. What will be output of the following C program? #include int main() {int goto=5; printf("%d",goto); return 0;}

A) 5

B) 10

C) **

D) compilation error


2. Output of the following C program fragment is. x=5; y=x++; printf("%d %d", x,y);

A) 5, 6

B) 5, 5

C) 6, 5

D) 6, 6


3. What will be output of the following C program? #include int xyz=10; int main() { int xyz=20; printf("%d", xyz); return 0;}

A) 10

B) 20

C) 30

D) compilation error


4. Following program fragment. main(){ printf("%p\n", main( ) ); }

A) Prints the address of main function

B) Prints 0

C) Is an error

D) In an infinite loop


5. What will be output of the following program? #include int main() {int a=2, b=7, c=10; c=a==b; printf("%d",c); return 0;}

A) 0

B) 7

C) 10

D) 2


6. What is the output of the following program segment? main( ) { long i=65536; printf("%d\n", i); }

A) 0

B) 65536

C) -1

D) 65


7. What will be the output of the program? # include 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); return0;}

A) 2, 1, 15

B) 1, 2, 5

C) 3, 2, 15

D) 2, 3, 20


8. What is the output of the following program segment? main( ) { int=1; do { printf("%d . . ", i); } while (i--); }

A) 0 . . 1 . .

B) 1 . . 0 . .

C) 0

D) -1


9. Output of the program below is. int i; main( ) { printf("%d", i); }

A) 1

B) 0

C) -1

D) Null


10. What will be the output of the following program? main( ) { int i=5; printf("%d", i=++i==6); }

A) 0

B) 7

C) 6

D) 1




Answers:




1. What will be output of the following C program? #include int main() {int goto=5; printf("%d",goto); return 0;}

A) 5

2. Output of the following C program fragment is. x=5; y=x++; printf("%d %d", x,y);

C) 6, 5

3. What will be output of the following C program? #include int xyz=10; int main() { int xyz=20; printf("%d", xyz); return 0;}

B) 20

4. Following program fragment. main(){ printf("%p\n", main( ) ); }

A) Prints the address of main function

5. What will be output of the following program? #include int main() {int a=2, b=7, c=10; c=a==b; printf("%d",c); return 0;}

A) 0

6. What is the output of the following program segment? main( ) { long i=65536; printf("%d\n", i); }

A) 0

7. What will be the output of the program? # include 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); return0;}

C) 3, 2, 15

8. What is the output of the following program segment? main( ) { int=1; do { printf("%d . . ", i); } while (i--); }

B) 1 . . 0 . .

9. Output of the program below is. int i; main( ) { printf("%d", i); }

B) 0

10. What will be the output of the following program? main( ) { int i=5; printf("%d", i=++i==6); }

D) 1



Related Posts

 

Share this

Related Posts

Previous
Next Post »