CJCoding With Joseph
← Back to Question List
C Code Walkthrough #15

While Loop Sum 1 to 5

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