In programming some time we need to use some mathematical operations. In math.h header defines various mathematical functions. Some important of them are pow and sqrt.. function of pow and sqrt is already defined in math.h header file. Let see how to use them
POW
Function pow is used for find out power of any integer. For example if we need to find out 25 then we use it.
Now let’s write the code
Function sqrt used when we try to find out square root of any integer. For example if we need to find out √3 then we use it.
Now let’s write the code
POW
Function pow is used for find out power of any integer. For example if we need to find out 25 then we use it.
Now let’s write the code
#include<stdio.h>
#include<math.h>
void main()
{
float x,y,z;
printf("enter the value");
scanf("%f",&x);
printf("enter the power");
scanf("%f",&y);
z=pow(x,y);
printf("the answer is: %.2f",z);
}
The output of above program is#include<math.h>
void main()
{
float x,y,z;
printf("enter the value");
scanf("%f",&x);
printf("enter the power");
scanf("%f",&y);
z=pow(x,y);
printf("the answer is: %.2f",z);
}
enter the value 2
enter the power 5
the answer is: 32.00
SQRTenter the power 5
the answer is: 32.00
Function sqrt used when we try to find out square root of any integer. For example if we need to find out √3 then we use it.
Now let’s write the code
#include<stdio.h>
#include<math.h>
void main()
{
float x, z;
printf("enter the value");
scanf("%f",&x);
z=sqrt(x);
printf("the answer is: %.2f",z);
}
The output of above program is#include<math.h>
void main()
{
float x, z;
printf("enter the value");
scanf("%f",&x);
z=sqrt(x);
printf("the answer is: %.2f",z);
}
enter the value 3
the answer is: 1.73
the answer is: 1.73

0 comments:
Post a Comment