0% found this document useful (0 votes)
53 views1 page

Add Two Numbers C++

The program prompts the user to enter two integers, stores them in variables, calculates the sum, difference, product, and quotient of the integers, and prints out the results. It declares integer variables to store the user input and results of the calculations, uses cin and cout to get input and display output, performs the basic arithmetic operations on the integers, and returns 0 at the end.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views1 page

Add Two Numbers C++

The program prompts the user to enter two integers, stores them in variables, calculates the sum, difference, product, and quotient of the integers, and prints out the results. It declares integer variables to store the user input and results of the calculations, uses cin and cout to get input and display output, performs the basic arithmetic operations on the integers, and returns 0 at the end.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

/*

* Prompt user for two integers and print their sum, difference, product and
quotient
* (IntegerArithmetic.cpp)
*/
#include <iostream>
using namespace std;

int main() {
int firstInt; // Declare a variable named firstInt of the type int (integer)
int secondInt; // Declare a variable named secondInt of the type int
int sum, difference, product, quotient;
// Declare 4 variables of the type int to keep the results

cout << "Enter first integer: "; // Display a prompting message


cin >> firstInt; // Read input from keyboard (cin) into
firstInt
cout << "Enter second integer: "; // Display a prompting message
cin >> secondInt; // Read input into secondInt

// Perform arithmetic operations


sum = firstInt + secondInt;
difference = firstInt - secondInt;
product = firstInt * secondInt;
quotient = firstInt / secondInt;

// Print the results


cout << "The sum is: " << sum << endl;
cout << "The difference is: " << difference << endl;
cout << "The product is: " << product << endl;
cout << "The quotient is: " << quotient << endl;

return 0;
}

You might also like