C Programming · Question 24 · Medium
What will be the output of the following C program?
#include <stdio.h>
int main(void) {
int s = 0;
for (int i = 1; i <= 10; i++) {
if (i % 3 == 0)
continue;
if (i == 8)
break;
s += i;
}
printf("%d", s);
return 0;
}
- 28
- 19
- 37
- 13
Answer and explanation
Answer: B. 19
Explanation: Multiples of 3 are skipped and the loop stops at i = 8, so s = 1 + 2 + 4 + 5 + 7 = 19.
Previous: What will be the output of the following C program? · Next: What will be the output of the following C program?
Practise c programming
Try a fresh set of c programming questions with an explanation after every answer, free and without signing up: C Programming practice. Or sit a full placement mock test.
More c programming questions
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
More technical & programming practice
Java · Python · Data Structures · Algorithms · Object-Oriented Programming · DBMS · SQL · Operating Systems
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge