What will be the output of the following C program segment? #include <stdio.h>…

BEL Probationary Engineer 2025

What will be the output of the following C program segment?

#include <stdio.h>
int main() {
    int i = 1, sum = 0;
    do {
        if (i % 2 == 0)
            sum += i;
        i++;
    } while (i <= 5);
    printf("%d", sum);
    return 0;
}
  1. A.

    10

  2. B.

    6

  3. C.

    4

  4. D.

    8

Attempted by 125 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…