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

Wednesday, December 3, 2014

Write a program to enter multiple values using for loop and calculate sum of all numbers in C.

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

/*Program to enter multiple values using for 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);

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

sum=sum+val;

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

}

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

getch();
}




No comments: