I’m trying to make program for
1+2+3+…+1000 using for loop in C language.I already wrote this but i don’t know why it’s not working
my code is here-
#include <stdio.h>
int main()
{
int i, n, sum;
printf("Please enter the value of n: ");
scanf("%d", &n);
for(i = 1, sum = 0; i <= n; i++){
sum = sum + 1;
}
printf("Summation is %d\n", sum);
return 0;
}
Please anyone help me,I will grateful to you
Thank you~