#include<stdio.h>
#include<conio.h>
void main()
{
int i, limit, no[97], sum=0;
clrscr();
printf("How many numbers you want to enter? ");
scanf("%d", &limit);
printf("\nEnter %d numbers one by one\n", limit);
for(i=0; i<limit; i++)
{
printf("Enter number %d: ", i+1);
scanf("%d", &no[i]);
}
for(i=0; i<limit; i++)
{
sum = sum + no[i];
}
printf("\n\nSum = %d", sum);
getch();
}
/*
How many numbers you want to enter? 5
Enter 5 numbers one by one
Enter number 1: 34
Enter number 2: 42
Enter number 3: 56
Enter number 4: 76
Enter number 5: 99
Sum = 307
*/
No comments:
Post a Comment