C++ Programming/Code/Variables/Examples/Adds two numbers and prints their sum

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search
// This program adds two numbers and prints their sum.
#include <iostream.h>
 
int main()
{
  int a = 123;
  int b (456);
  int sum;
 
  sum = a + b;
 
  std::cout << "The sum of " << a << " and " << b << " is " << sum << "\n";
 
  return 0;
}