//Print sum of first n numbers
#include<stdio.h>
void main()
{
int i, n, sum = 0;
printf("Enter a positive integer: ");
scanf("%d",&n);
for(i=1; i <= n; i++)
{
sum += i; // sum = sum+i;
}
printf("Sum of first n numbers is = %d",sum);
return 0;
}
Enter a positive integer: 8
Sum of first n numbers is = 36