C Language: Maths Inbuilt Functions 2


X to the power y


Same as pow for long double


Any number raise to the power 10


same as above for long double

pow(2,3) 8
pow(3,2) 9
pow10(2) 100
pow10(3) 1000

#include <stdio.h>

int main()
    double x = 2.0, y = 3.0;
    long double x1=2.0,y1=5.0;
    float a=2,b=3;
    printf("%f raised to %f is %f\n",a,b,pow(a,b));
    printf("%lf raised to %lf is %lf\n", x, y, pow(x,y));
    printf("%Lf raised to %Lf is %Lf\n", x1, y1, powl(x1, y1));
    printf("\n10 raised to the power 2 is %lf\n",pow10(2));
    printf("\n10 raised to the power 3 is %Lf\n",pow10(3));
	return 0;
/* Output */

2.000000 raised to 3.000000 is 8.000000
2.000000 raised to 3.000000 is 8.000000
-0.000000 raised to 0.000000 is 8.125012
10 raised to the power 2 is 100.000000
10 raised to the power 3 is 1000.000000


Square root of a number


Same for long double

#include <stdio.h>

int main()
    double x = 4.0, result;
    double x1=64,r1;
    result = sqrt(x);
    printf("square root of %lf is %lf\n",x, result);
    printf("square root of %lf is %lf\n",x1,r1);
	return 0;
/* Output */

square root of 4.000000 is 2.000000
square root of 64.000000 is 8.000000

C Language Programming Tutorial

C Language Tutorial Home     Introduction to C Language     Tokens     If Condition      goto statement and Labelname     Switch Statements     For loop     While Loop     Do while loop     break and continue     Functions     Recursion     Inbuild Functions     Storage Classes     Preprocessor     Arrays     Pointers     Structures and Unions     File Handling     Projects