30 Points Each
[C++] problem
Computer science
Q. Program to calculate the square of any number.
Try to explain nicely.
No Spam
Answers
Answered by
8
Thanks for the question :
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num result;
cout<<"\n Enter any Number\n";
cin>>num;
result = num*num;
cout<<"\n The result is"<<result;
getch();
}
Attachments:
VickyskYy:
manhoos answer
Answered by
0
#include<iostream.h> #include<conio.h> #include<math.h> void main() { int num,ans; clrscr(); cout<<"Enter any Num: "; cin>>num; ans=pow(num,0.5); cout<<"\n Squre of "<<num<<" is: "<<ans; getch(); }
Output
Enter any Num: 9 Squre of 9 is: 3
Explanation of Code
pow() is a predefined function in math.h header file, it is used for calculate power of any number
Output
Enter any Num: 9 Squre of 9 is: 3
Explanation of Code
pow() is a predefined function in math.h header file, it is used for calculate power of any number
Similar questions