C++ Program to Add n Numbers

« Previous Program Next Program »

Add n Numbers in C++

To add n numbers in C++ Programming, you have to ask to the user to enter the value of n (i.e., how many numbers he/she want to enter to all the numbers), then ask to enter n numbers to perform the addition of all the n numbers to display the result on the screen as shown here in the following program.

C++ Programming Code to Add n Numbers

Following C++ program first ask to the user to enter the value of n and then ask to enter the n Number to add them.

This C++ program add all n numbers entered by the user.

/* C++ Program - Add n Numbers */
void main()
	int i, n, sum=0, num;
	cout<<"How many number you want to enter and add them ?";
	cout<<"Enter "<<n<<" number :";
	cout<<"Sum of all the "<<n<<" number is "<<sum;

When the above C++ program is compile and executed, it will produce the following result:

C++ program to add n numbers

Same Program in Other Language

You may like the same program in other programming languages:

« Previous Program Next Program »


Quick Links
Signup - Login - Give Online Test