Programmers learn & share
18 views

Squaring any number in mathematics is pretty simple and in C++ it is similar. We can calculate the square of any number by multiplying it by itself. And that's it, that is all for today.

 

How to calculate the square of any number in c++?

 

Approach → 

Define two int in the program. First int will store the number and the second will store the square of the number.

#include <iostream>
using namespace std;

int main()
{
     int num,sqr;
     cout << "For getting the square enter the number: ";
     cin >> num;
     sqr = num*num;
     cout << "\nSquare of the number you entered is: " << sqr << endl;
     return 0;
}

 

I know it is a very small and very easy article but it is what it is.

If you have any doubt ask freely in the comment section.

posted May 22 in c++ by (100 points)   | 18 views
2,227 questions
2,734 answers
59 comments
241 users