Skip to content

Commit 030a354

Browse files
solution of square number
1 parent 65f27e5 commit 030a354

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

square_number/en.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Dimik - Square Number
2+
3+
You have to write a program to find out whether a number is a perfect square or not.
4+
5+
### Solution
6+
* Store the square root of the number in a variable
7+
* check if the multiplication of that variable is equal to input the number
8+
9+
# C++
10+
```cpp
11+
#include <iostream>
12+
#include <math.h>
13+
using namespace std;
14+
15+
int main()
16+
{
17+
int test_case;
18+
cin >> test_case;
19+
20+
for (int i = 1; i <= test_case; i++)
21+
{
22+
int num;
23+
cin >> num;
24+
int a = sqrt(num);
25+
if (a * a == num)
26+
{
27+
cout << "YES" << endl;
28+
}
29+
else
30+
{
31+
cout << "NO" << endl;
32+
}
33+
}
34+
35+
return 0;
36+
}
37+
```

0 commit comments

Comments
 (0)