the user */
#include <stdio.h>
#include <stdlib.h>
int main()
{
int N;
int ctr;
int sum=0;
printf("Enter the value of N\n");
scanf("%d",&N);
for(ctr=1;ctr<=N;ctr++)
{
sum=sum+ctr;
}
printf("The sum of the first %d natural numbers is %d",N,sum);
return 0;
}
No comments:
Post a Comment