Sum of Natural numbers

C Program to Sum of Natural numbers

/* This program is solved using while loop. */
#include
int main()
{
int n, count, sum=0;
printf(“Enter an integer: “);
scanf(“%d”,&n);
count=1;
while(countn */
{
sum+=count; /* sum=sum+count */
++count;
}
printf(“Sum = %d”,sum);
return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *