by @CodingExample

C++ program to add three numbers

Home » cpp » C++ program to add three numbers

Here is an example program of how to add three numbers in c++.

#include <iostream>
using namespace std;

int main()
{
   int firstNumber, secondNumber, thirdNumber, sum;

   cout << "Enter three integers to add\n";

    // taking input of three numbers
   cin >> firstNumber >> secondNumber >> thirdNumber;

    // adding three numbers
   sum = firstNumber + secondNumber + thirdNumber ;

   // displaying sum
   cout <<"Sum of three numbers is: " << sum << endl;
   return 0;
}