Monday, 30 April 2018

Program to calculate the sum of N number in c using while statement

/* sum of n number */
# include <stdio.h>
void main ()
{
int a,n ;
int i=0 ;
int sum =0 ;
clrscr () ;
printf ("/n how many number you want add :") ;
scanf ("%d", & n) ;
while ( i < n )
{
printf ("/n enter a number :") ;
scanf ("%d", & a) ;
sum = sum+a ;
i++ ;
}
printf ("/n sum =%d", sum) ;
getch () ;
}

No comments:

Post a Comment

Featured post

Program to find Volume of given box in java

class volume { public static void main (String args []) { int l=5,b=6,h=10; int volume; volume=l*b*h; System.out.println (" vol...