//sum of all numbers from 1 to n using for loop
#include<stdio.h>
int main()
{
int n,sum=0,i;
printf("Enter n = \n");
scanf("%d",&n);
for(i=1;i<=n;i++)
sum=sum+i;
printf("Sum of 1 to %d= %d",n,sum);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: