Get 50% OFF on AI & Full Stack Courses
📞 Call Now: +91 8448811320
Home › Community › WAC to find the sum of first n nos. using for loop.

WAC to find the sum of first n nos. using for loop.

Soham  •  Jul 17, 2026  •  44 views
0

1 Answers

Soham
Jul 17, 2026
#include <stdio.h>

int main() {
int num, sum = 0;

printf("Choose Number: ");
scanf("%d", &num);

for (int i = 1; i <= num; i++) {
sum = sum + i;
}

printf("SUM: %d\n", sum);

return 0;
}

Your Answer

Will not be displayed publicly
Talk to Advisor Online now
1