C++: A simple program to find the total of five values

October 2017



Issue


I need a simple program that will allow me to enter 5 values and sum them up. How can this be implemented under C++?

Solution


Try this code:
#include<stdio.h> 
#include<conio.h> 
main() 
{ 
int num1,num2,num3,num4,num5; 
printf("\t*****SUMA*****\n"); 
printf("Enter number 1: "); 
scanf("%d",&num1); 
printf("Enter number 2: "); 
scanf("%d",&num2); 
printf("Enter number 3: "); 
scanf("%d",&num3); 
printf("Enter number 4: "); 
scanf("%d",&num4); 
printf("Enter number 5: "); 
scanf("%d",&num5); 
printf("\nel resultado de la usma es:%d",num1+num2+num3+num4+num5); 
getch; 
return 0; 
}


Thanks to tortugo for this tip.
Published by jak58. Latest update on November 9, 2012 at 05:28 AM by jak58.
This document, titled "C++: A simple program to find the total of five values," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).