C++ Programming Code Examples C++ > For Loops and While Loops Code Examples enter the value of n and then ask to enter the n Number to add them enter the value of n and then ask to enter the n Number to add them 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. 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. #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<<" number :"; for(i=0;i<n;i++) { cin>>num; sum=sum+num; } cout<<"Sum of all the "<<n<<" number is "<<sum; getch(); }