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:
Post a Comment