Print numbers entered and find sum using do while statement in C program

//print number entered and find sum using do while
#include<stdio.h>
#include<conio.h>
int main()
{
int n,i=1,sum=0;
printf("Enter the value of N:");
scanf("%d",&n);
printf("First %d numbers are\n",n);
do
{
printf("%7d",i);
sum=sum+i;
i++;
}
while(i<=n);
printf("\n\nSum=%d\n",sum);
return 0;
}

Leave a Reply

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

Enter Captcha Here : *

Reload Image