-->

Facebook

Jasper Roberts - Blog

Monday, October 13, 2014

WRITE A C PROGRAM TO CALCULATE SUM OF N NUMBERS.

#include<stdio.h>
#include<conio.h>

void main()
{
int i=1,sum=0,no;
clrscr();

printf(“Enter the number:”);
scanf(“%d”,&no);

while(i<=no)
{

     sum = sum + i;
     i++;
}

printf(“sum of %d is %d”,no,sum);
getch();
}



Output:
Enter the number: 5

sum of 5 is 15



sum of n numbers using while loop-cpu(2110003) in pdf format 

No comments:

Post a Comment