- Home
- Course Category
- Course Result
- Course Detail
Hot Line: 0124-2383121
Course Introduction
Programs for practice
C++ program to add all n numbers entered by the user
Source Code: Add n Numbers
/* C++ Program - Add n Numbers */ #include<iostream.h> #include<conio.h> void main() { clrscr(); int i, n, sum=0, num; cout<<"How many number you want to enter and add them ?"; cin>>n; cout<<"Enter "<<n<<" numbers :"; for(i=0;i<n;i++) { cin>>num; sum=sum+num; } cout<<"Sum of all the "<<n<<" numbers is "<<sum; getch(); }Output
How many number you want to enter and add them ? 3 Enter 3 numbers: 1 2 3 Sum of all the 3 numbers is 6