C MCQ Set-21 : Multiple Choice Questions in C Set-21

Set-26 C MCQ

  1. What is the output of the following program?

    int main()
    {
    char r=132;
    printf(“%d\n”, r);
    }

a. -132
b. -124
c. 132
d. None

Answer: b


  1. Select the most appropriate output for the following C code:

    main()
    {
    printf(“%d %d %d %d”,-6%5,6%5,-6%-5,6%-5);
    }

a. -1 1 -1 1
b. 1 -1 1 -1
c. 1 -1 -1 1
d. Error

Answer:a


3. Select the most appropriate output of the following C code:

main()
{
int x=-2,b;
printf(“%d %i”,b,b=x=9/x);
}
a. Garbage -4
b. Garbage -2
c. -4 -4
d. Error

Answer:c


4. Select the most appropriate output for the following C code:

int main()
{ int i = 90;
int j = (i++, –i, i++);
printf(“%d %d\n”, i, j);
}
a. 91 91
b. 90 90
c. 91 90
d. Compiler Dependent

Answer: c


5.Select the most appropriate output for the following C code:

main()
{ int x=-7810,d,e;
d=!x;
e=~x;
printf(“%d %d”,d,e);
}

a. 0 7811
b. 0 7809
c. 1 7809
d. 1 0

Answer:b


6.Select the most appropriate output for the following C code:

main()
{
int r = -5, s = 1;
s = r &= s && 100;
printf(“%d %d”,r,s);
}

a. -100 1
b. 1 0
c. 1 1
d. Error

Answer: c


7.Select the most appropriate output for the following C code:

int main()
{ int a1 = 51;
int b1 = 0;
int c2 = a1 || –b1;
int d3 = a1– && –b1;
printf(“a1 = %d, b1 = %d, c2 = %d, d3 = %d”, a1, b1, c2, d3);
}

a. a1 = 50, b1 = -1, c2 = 1, d3 = 1
b. a1 = 50, b1 = -2, c2 = 1, d3 = 1
c. a1 = 51, b1 = -1, c2 = 1, d3 = 1
d. None

Answer: a
C MCQ Set-21 Explanation


  1. What is the output of this C code?

    void main()
    {
    int x = 10;
    if (x = 0)
    printf(“Its zero”);
    else
    printf(“Its not zero”);
    }

A. Its not zero
B. Its zero
C. Run time error
D. None

Answer :A
C MCQ Set-21 Explanation


  1. What is the output of this C code?

    void main()
    {
    int k = 8;
    int x = 0 == 1 && k++;
    printf(“%d %d”, x, k);
    }

    A. 0 9
    B. 0 8
    C. 1 9
    D. 1 8

    Answer :B

10. What is the output of this C code?

void main()
{
char a = ‘a’;
int x = (a % 10)++;
printf(“%d”, x);
}

A. 6
B. Junk value
C. Compile time error
D. 7

Answer :C


Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *