Programming for Problem Solving (3110003) MCQs

MCQs of Control structure in C

Showing 21 to 30 out of 41 Questions
21.
What is the output?

int main()
{
    int x = 0;
    if (x == 1)
        if (x >= 0)
            printf("true\n");
        else
            printf("false\n");
}

(a) true
(b) false
(c) blank
(d) Error
Answer:

Option (c)

22.
Choose a C Conditional Operator from the list.
(a) ?:
(b) :?
(c) :<
(d) <:
Answer:

Option (a)

23.
What is alternate name of conditional operator?
(a) Comparison operator
(b) If-else Operator
(c) Binary operator
(d) Ternary operator
Answer:

Option (d)

24.
Choose a syntax for C Ternary Operator from the list.
(a) condition ? expression1 : expression2
(b) condition : expression1 ? expression2
(c) condition ? expression1 < expression2
(d) condition < expression1 ? expression2
Answer:

Option (a)

25.
What is the output?

void main()
{
    int a=0;
    a = 5<2 ? 4 : 3;
    printf("%d",a);
}

(a) 4
(b) 3
(c) 5
(d) 2
Answer:

Option (b)

26.
The C code ‘for( ; ; )’ represents an infinite loop. It can be terminated by ___
(a) break
(b) exit(0)
(c) abort()
(d) terminate
Answer:

Option (a)

27.
Which for loop has range of similar indexes of ‘i’ used in for (i = 0;i < n; i++)?
(a) for (i = n; i>0; i--)
(b) for (i = n; i >= 0; i--)
(c) for (i = n-1; i>0; i--)
(d) for (i = n-1; i>-1; i--)
Answer:

Option (d)

28.
What is the output?

void main()
{
    int k = 0;
    for (k)
        printf("Hello");
}

(a) Error
(b) Hello
(c) Blank
(d) Infinite loop
Answer:

Option (a)

29.
What is the output?

void main()
{
    int k;
    for (k = -3; k < -5; k++)
        printf("Hello");
}

(a) Hello
(b) Infinite Hello
(c) Error
(d) Blank
Answer:

Option (d)

30.
In the given loop construct, which one is executed only once always? for(exp1; exp2; exp3)
(a) exp1
(b) exp3
(c) exp1 and exp3
(d) exp1, exp2 and exp3
Answer:

Option (a)

Showing 21 to 30 out of 41 Questions