write a program that calculates the sum of n numbers
1
Expert's answer
2012-09-07T10:45:10-0400
#include<stdio.h> #include<conio.h> main() { int num, n,sum=0,i=0; printf("Enter the number of elements to be added: "); scanf("%d",&n); printf("Enter %d numbers",n); while(i<n) {
scanf("%d",&num); sum=sum+num; i=i+1; } printf("The sum of %d numbers is %d",n,sum); getch(); }
Comments