CJCoding With Joseph
15free / daySign inCreate account
Back to Code Walkthrough

While Loop Sum 1 to 5

C code walkthrough · Question 15
easyLoops

Code

Read carefully. What does this print?
1#include <stdio.h>
2int main() {
3 int i = 1, sum = 0;
4 while (i <= 5) {
5 sum += i;
6 i++;
7 }
8 printf("%d\n", sum);
9 return 0;
10}

Your answer