GATE CSE C Programming Practice Test – Flow Control | Set 1

Questions 6-10 of 100

Your score 0/100 0 answered
Correct 0 Incorrect 0 Unanswered 100 Accuracy 0%

Question 6

MCQ · Single Correct 1 mark

What will be printed by the following program?

C
#include <stdio.h>
int main(void) {
    int i = 0;
    while (i < 5) {
        if (i == 3) {
            i++;
            continue;
        }
        printf("%d ", i);
        i++;
    }
    return 0;
}
Answers for question 6

Question 7

MCQ · Single Correct 1 mark

Consider the following code snippet:

C
#include <stdio.h>
int main(void) {
    int c = 2;
    switch (c) {
        case 1: printf("A"); break;
        case 2: printf("B");
        case 3: printf("C"); break;
        default: printf("D");
    }
    return 0;
}
Answers for question 7

Question 8

MCQ · Single Correct 1 mark

What is the output of the following C code?

C
#include <stdio.h>
int main(void) {
    int i = 0;
    do {
        printf("%d ", i);
        i++;
    } while (i < 0);
    return 0;
}
Answers for question 8

Question 9

MCQ · Single Correct 1 mark

What will be the output of the C program below?

C
#include <stdio.h>
int main(void) {
    int k = 1;
    if (k == 1)
        if (k == 2)
            printf("Two");
        else
            printf("One");
    return 0;
}
Answers for question 9

Question 10

MCQ · Single Correct 1 mark

What is the return value/behavior of the following loop?

C
#include <stdio.h>
int main(void) {
    int a = 10;
    while (a --> 0) {
        ;
    }
    printf("%d", a);
    return 0;
}
Answers for question 10
Scroll to Top