0
Thanks

A few words of thanks would be greatly appreciated.

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

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.

0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
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).