# Math Functions in C Programming

C math functions with examples; In this tutorial, i am going to show you math or mathematical functions in a c programming language with examples.

## Math Functions in C Programming with Example

Here, i will show you what is math functions and how to use it in c programming with examples:

• What are math functions in C
• List of Math Functions in C
• Examples of Math Functions in C
• Floor function in c
• C program to find square root of a number with sqrt
• C program to round float number
• C program to find power of a number using pow function
• C program for exponential function

### What are math functions in C

Math functions are used to perform mathematical operations such as sqrt(), pow(), ceil(), floor() etc. in the C programming language.

For example; If you want to find the square root of a number in the C program. For this, you have to use sqrt() meth function in c program.

### List of Math Functions in C

C Programming allows us to perform mathematical operations through the functions defined in <math.

There is the list of math functions in c; as follows:

### Examples of Math Functions in C

• Floor function in c
• C program to find square root of a number with sqrt
• C program to round float number
• C program to find power of a number using pow function
• C program for exponential function

### Floor function in c

Using the math floor() function, you can find largest integer that is smaller than or equal to x (ie: rounds downs the nearest integer); as follows:

```#include <stdio.h>
#include <math.h>
int main()
{
double f= -9.33;
int final;
final = floor(f);
printf("Floor value of %.2f = %d", f, final);
return 0;
}```

### C program to find square root of a number with sqrt

Using the math sqrt() function, you can find square root of a number with sqrt in c program ; as follows:

```#include <stdio.h>
#include <math.h>
int main()
{
double n,output;
printf("Enter a number\n");
scanf("%lf", &n);
output = sqrt(n);
printf("Square root of %.2lf = %f", n,output);
return 0;
}```

### C program to round float number

Using the math round() function, you can round the nearest value of a given input in c program; as follows:

```#include <stdio.h>
#include <math.h>
int main ()
{
for(double r=10;r<=20;r+=1.1)
printf("round of  %.1lf is  %.1lf\n", r/5.0, round(r/5.0));
return 0;

}```

### C program to find power of a number using pow function

Using the math pow() function, you can find power of a number using pow function in c program; as follows:

```#include <stdio.h>
#include <math.h>
int main()
{
int r, ba, expr;
printf("\n Enter the Base numbers :  ");
scanf("%d", &ba);
printf("\n Enter the Exponent numbers :  ");
scanf("%d", &expr);
r = pow(ba, expr);
printf("\n The result of %d Power %d = %d ", ba, expr ,r);
return 0;
}```

### C program for exponential function

Using the math exp() function, you can computes e (2.71828) raised to the power of the given argument in c program; as follows:

```#include <math.h>
#include <stdio.h>

int main() {
double x = 12.0, result;
result = exp(x);
printf("Exponential of %.2lf = %.2lf", x, result);
return 0;
}```

Categories C