168k views
2 votes
Write a complete program that declares an integer variable, reads a value from the keyboard into that variable, and writes to standard output a single line containing the square of the variable's value. Besides the line and the number it contains, nothing else should be written to standard output.

User PublicJorn
by
5.7k points

1 Answer

6 votes

Answer:

// here is code in C++.

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

// variables

double num;

// read discriminant

cin>>num;

// calculate square of the input

double result=num*num;

// print the square number

cout<<result<<endl;

return 0;

}

Step-by-step explanation:

Declare a variable "num".Read the value of "num" from keybord.Then calculate square of the input number.Print the square of input number.

Output:

5

25

User ReallyJim
by
5.1k points