- #1
charmedbeauty
- 271
- 0
Homework Statement
I want to create a program that prints the sum of integers k for k(1-20)
ie,
k sum
1 1
2 3
3 6
4 10
5 .
6 .
.
.
.
.
.
20 .
in that format
Homework Equations
The Attempt at a Solution
#include <stdio.h>
int main(int argc,char * argv[]){
int i=0, sum=0, n=20;
for (i=0;i<n;++i);{
sum=sum+i;
printf("%d = %4d\n",i, sum);
}
return 0;
}
I don't want the user to enter an input (hence no scanf) I just want the program to run through integers 1-20 and print there sum.
when I run this it just prints 20 = 20??
help please!
Thanks.