Write a program that will print sum of N integers entered by the user.
PROGRAM:
#include <iostream.h>
#include <conio.h>
void main() {
clrscr();
int terms,num,sum=0;
cout<<"Please enter the number of terms to add: ";
cin>>terms;
for(int i=1;i<=terms;i++) {
cout<<"enter number "<<i<<": ";
cin>>num;
sum+=num;
}
cout<<"Your sum is: "<<sum;
getch();
}//end of the program
No comments:
Post a Comment