0% found this document useful (0 votes)
30 views11 pages

Practice - MCQ

The document presents a series of programming questions focused on C language concepts, including array manipulation, conditional statements, and output formatting. Each question is followed by multiple-choice answers, testing the reader's understanding of C syntax and behavior. The questions cover a range of topics from basic array initialization to control flow and output formatting.

Uploaded by

p42477758
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views11 pages

Practice - MCQ

The document presents a series of programming questions focused on C language concepts, including array manipulation, conditional statements, and output formatting. Each question is followed by multiple-choice answers, testing the reader's understanding of C syntax and behavior. The questions cover a range of topics from basic array initialization to control flow and output formatting.

Uploaded by

p42477758
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

1. What will be the output of the program?

#include<stdio.h>

void main()

int a[5] = {5, 1, 2, 20, 25};

int i, j, m;

i = ++a[2];

j = a[2]++;

m = a[i++];

printf("%d, %d, %d", i, j, m);

A.3, 3, 15

B.4, 3, 20

C.2, 1, 20

D.1, 2, 5

2. What will be printed after execution of the following code?

void main()

int arr[10] = {1,2,3,4,5};

printf("%d", arr[5]);

A.Garbage Value

B.5

C.6

D.0
3. What will be the output of the following program?

void main()

int str1[] = {1,2,3,4};

int str2[] = {1,2,3,4};

if(str1==str2)

printf("Equal");

else

printf("Unequal");

A.Equal

B.Unequal

C.Error

D. None of these

4. What will be the output of the following code?

int main() {

int a[10];

printf("%d %d", a[-1], a[12]);

A.0 0

B. Garbage value 0

C. 0 Garbage Value

D. Garbage Value Garbage Value


5. What will be the output of the program?

int main()

int arr[2] = {10};

printf("%d", 0[arr]);

return 0;

A.1

B.0

C.10

D.Error

6. What will be the output of the program?

int main()

{ int i;

int a[5]={1,2,3,4,5};

for(i=5; i>=2; i--)

a[i-1] =a [i-2];

for(i=0 ;i<5; i++)

printf("%d ",a[i]);

A.1 1 2 3 4

B.1 4 5

C.1 2 3 4 5

D.2 4
7. What will be the output of the program?

int main(void)

int i;

int a[5]={2,4,6,8,10};

for(i=4;i>=0;i--)

printf("%d ",++a[i]);

return 0;

A. 11 9 7 5 3

B. Error

C. 10 8 6 4 2

D. None of these

8. If the size of the array is less than the number of initializers then.

A. Extra values are being ignored


B. Generates an error message
C. Size of Array is increased
D. Size is neglected when values are given

9. What will be the output of the following C code?

#include <stdio.h>

void main()

int i , j ;

for (i = 0; i < 5; i++)

for (j = 0;j < 4; j++){


if (i > 1)

break;

printf("Hi \n");

a) Hi is printed 5 times

b) Hi is printed 9 times

c) Hi is printed 7 times

d) Hi is printed 4 times

10. What will be the output of the following C code?

int main()

int i = 0;

for (i = 0;i < 5; i++)

if (i < 4)

printf("Hello");

break;

a) Hello is printed 5 times

b) Hello is printed 4 times

c) Hello is printed 1 time

d) Hello is printed 3 times


11. What will be the output of the following C code?

#include <stdio.h>

void main()

int x = 5;

if (x < 1)

printf("hello");

if (x == 5)

printf("hi");

else

printf("no");

a) hi

b) hello

c) no

d) error

12. What will be the output of the following C code?

int main() {

int x = 5;

if (0);

printf("hello"); }

a) It will display hello

b) It will throw an error

c) Nothing will be displayed

d) Compiler dependent
13. What will be the output of the following C code?

float main()

int x = 0;

if (x == 1)

printf("hi");

else if (x == 2);

printf("how are u");

a) Error

b) how are u

c) hello

d) hi hello

14. What will be the output of the following C code? (Assuming that we have entered the value 1 in the
standard input)

#include <stdio.h>

void main() {

double ch;

printf("enter a value between 1 to 2:");

scanf("%lf", &ch);

switch (ch)

case 1:

printf("1");

break;

case 2:
printf("2");

break;

a) Compile time error

b) 1

c) 2

d) Varies

15. What will be the output of the following C code? (Assuming that we have entered the value 2 in the
standard input)

char main()

int ch;

printf("enter a value between 1 to 2:");

scanf("%d", &ch);

switch (ch)

case 1:

printf("1\n");

break;

printf("Hi");

default:

printf("Hi");

printf("2\n");

}
a) 1

b) Hi2

c) Run time error

d) 2

16. What will be the output of the following C code?

#include <stdio.h>

int main()

int x = 1;

if (x == 1)

if (x == 2);

printf("inside if\n");

else if (x == 2)

printf("inside else if\n");

else if (x == 2)

printf("inside else\n");

a) inside if

b) inside else if

c) inside else

d) compile time error

17. What will be the output of the following C code?

int main()

int a = 1;
if (a--)

printf("True");

if (a++)

printf("False");

a) True

b) False

c) True False

d) No Output

18. What will be the output of the following C code?

int main()

int x = 98;

switch (x)

case 'b':

printf("yes ");

break;

case 98:

printf("no\n");

a) yes b) yes no

c) Duplicate case value error d) Character case value error


19. What will be the output of the following C code?

#include <stdio.h>

int main()

printf("%05d %5d %-5d", 32, 32, 32);

20. What will be the output of the following C code?

#include <stdio.h>

int main()

printf("%d %o %x %X", 15, 15, 15, 15);

return 0;

You might also like