Prompts for a number and then prints the square. - C++ File Stream

C++ examples for File Stream:cin

Description

Prompts for a number and then prints the square.

Demo Code

#include <iostream>
using namespace std;
int main()/* w  ww . java2s .  com*/
{
   double  x = 0.0;
   // Prompt and input value of x.
   cout << "Input a number and press ENTER: ";
   cin >> x;
   // Calculate and output the square.
   cout << "The square is: " << x * x << endl;
   return 0;
}

Result


Related Tutorials