Find square of the number by R4R Team

For finding the square of any number, we have many method but some methods are:
1.
number=3;
answer=number*number;
2.
number=3;
answer=pow(number,2);

-Here we find the sqaure of the number by the pow() function that are predefined in math library.
-We pass two argument in this function, first arguement is number and second argument is power.

program-

#include < stdio.h>
#include
int main()
{
int n,a;
printf("Enter number\n");
scanf("%d",&n);
a=pow(n,2);
printf("Square of %d is %d",n,a);
}


output-

Enter number
25
Square of 25 is 625

Enter number
4
Square of 4 is 16

-In this program, we include the math library by #include< stdio.h> so that pow() function do not give any kind of error.
- we take an input of the number and pass in pow(n,2) which return the sqaure of the number.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!