Brijmohan lal Sahu - Facebook
Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Wednesday, December 3, 2014

Program to enter multiple values using while loop and calculate sum of all numbers in C.





Code Box
---------------------------------------

/*Program to enter multiple values using while loop and calculate sum of all numbers */

#include<stdio.h>
#include<conio.h>
void main()
{
int num,i,sum,val;
clrscr();

sum=0;

printf("\nEnter numbers you want to enter:");
scanf("%d",&num);

i=1;while(i<=num)
{
printf("\nEnter %d value= ",i);
scanf("%d",&val);

sum=sum+val;

printf("\nSum is= %d",sum);

i++;
}

printf("\nTotal Sum= %d",sum);

getch();
}



No comments: