C++ Program to Add Three Numbers

Program description:- Write a C++ Program to add three numbers. Take three numbers, calculate the sum of them, display the result.

Steps to develop the program,

  • Declare three variables to hold/store the input values.
  • Take three numbers and store them in declared variables.
  • Declare a sum variable.
  • Calculate the sum of three numbers.
  • Display the result.
using namespace std;
int main()
   // variables
   int n1, n2, n3;
   int sum;

   // take input and store in variables
   cout << "Enter three numbers: ";
   cin >> n1 >> n2 >> n3;

   // calculate sum
   sum = n1 + n2 + n3;
   // display result
   cout << "Sum = " << sum << endl; 

   return 0;


Enter three numbers: 10 20 30
Sum = 60

Enter three numbers: -15 20 10
Sum = 15

If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or do you find anything incorrect? Let us know in the comments. Thank you!

Learn More C++ Programming Examples,

Leave a Comment

Your email address will not be published. Required fields are marked *