C++ program to take a number as input and calculate the square of that number


Following program shows how to take a number as input and calculate the square of that number.
In this program we get input from user and prints square of that number using following formula
Square of number = input X input

#include <iostream>

int main() {
	int input;
	std::cout << "Enter a number:";
	std::cin >> input;
	int result = input * input;
	std::cout << "Squre of " << input << " is " << result;
}

Output:

Enter a number: 6
Squre of 6 is 36