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

December 2016



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.

Related :

This document entitled « C++: A simple program to find the total of five values » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.