C++ Arithmetic Operator Print the square of the input value

Description

C++ Arithmetic Operator Print the square of the input value

#include <iostream>
using namespace std;
int main()//ww w .java  2  s . c  o  m
{
   int num, square;
   cout << "\n\n";  // Print two blank lines.
   cout << "What number do you want to see the square of? ";
   cin >> num;
   if (num <= 180)
   {
      square = num * num;
      cout << "The square of " << num << " is " << square << "\n";
   }
   if (num > 180)
   {
      cout << '\x07';   // BEEP
      cout << "\n* Square is not allowed for numbers over 180 *";
      cout << "\nRun this program again trying a smaller value.";
   }
   cout << "\nThank you for requesting square roots.\n";
   return 0;
}



PreviousNext

Related