C++ cin read int value

Description

C++ cin read int value

#include <iostream>
using namespace std;
#include <iomanip.h>
int main()/*from   w w w .  j av  a2s  .  c  o  m*/
{
   int num1, num2, ans;
   int her_ans;
   cout << "*** Math Practice ***\n\n\n";
   cout << "What is the first number? ";
   cin >> num1;
   cout << "What is the second number? ";
   cin >> num2;
   // Compute answer and give her a chance to wait for it.
   ans = num1 + num2;
   cout << "\nWhat do you think is the answer? ";
   cin >> her_ans;     // Nothing is done with this.
   // Prints answer after a blank line.
   cout << "\n" << num1 << " plus " << num2 << " is " << ans << "\n\nHope you got it right!";
   return 0;
}



PreviousNext

Related