Programming for Problem Solving (3110003) MCQs

MCQs of Programming Test 1

Showing 11 to 10 out of 20 Questions
11.

#include <stdio.h>
void main()
{
    int x = 10, y = 20, z = 5, i;
    i = x < y < z;
    printf("%d", i);
}

(a)

5

(b)

0

(c)

1

(d)

10

Answer:

Option (c)

12.

#include <stdio.h>
int main()
{
    printf("value is = %d", (10 ++));
    return 0;
}

(a)

10

(b)

11

(c)

compile time error

(d)

run time error

Answer:

Option (c)

13.

#include <stdio.h>
int main()
{
    int y = 10;
    if (y++ > 9 && y++ != 10 && y++ > 11)
        printf("%d", y);
    else
        printf("%d", y);
    return 0;
}

 
(a)

 11

(b)

13

(c)

12

(d)

None of above

Answer:

Option (b)

14.

#include <stdio.h>
int main()
{
    int i = 10;
    i = !i > 14;
    printf("i=%d", i);
    return 0;
}

(a)

 i=1

(b)

 i=0

(c)

 i=10

(d)

none of these

Answer:

Option (b)

15.

#include <stdio.h>
int main()
{
    int a = 3, b = 5, c, d;
    c = a, b;
    d = (a, b);
    printf("c=%d d=%d", c, d);
    return 0;
}

(a)

c=3 d=5

(b)

c=5 d=5

(c)

can’t be determined

(d)

none of these

Answer:

Option (a)

16.

#include <stdio.h>
int main()
{
    int y = 10;
    if (y++ > 9 && y++ != 11 && y++ > 11)
        printf("%d", y);
    else
        printf("%d", y);
    return 0;
}

(a)

11

(b)

14

(c)

13

(d)

12

Answer:

Option (d)

17.

#include <stdio.h>
int main()
{
    int a = 9;
    float x;
    x = a / 2;
    printf("%f", x);
    return 0;
}

(a)

4.000000

(b)

0

(c)

4

(d)

No output

Answer:

Option (a)

18.

#include <stdio.h>
int main()
{
    int a = 9;
    float x;
    x = (float)a / 2;
    printf("%f", x);
    return 0;
}

(a)

4.000000

(b)

 4.50

(c)

 4

(d)

4.500000

Answer:

Option (d)

19.

#include <stdio.h>
int main()
{
    int x;
    x = 5 > 8 ? 10 : 1 != 2 < 5 ? 20 : 30;
    printf("Value of x:%d", x);
    return 0;
}

(a)

20

(b)

30

(c)

Not Valid Expression

(d)

5

Answer:

Option (b)

20.

#include <stdio.h>
int main()
{
    int x;
    x = 5 < 8 ? 1 != 2 < 5 == 0 ? 10 : 20 : 30;
    printf("Value of x:%d", x);
    return 0;
}

(a)

10

(b)

20

(c)

30

(d)

0

Answer:

Option (a)

Showing 11 to 10 out of 20 Questions