C Math Functions

Beginner
8 min read
Updated: Nov 2026
30 tutorials
<math.h>

Definition and Usage

C math functions are the library calls you use for floating-point work: roots, powers, logs, trigonometry, rounding, and remainders. Most live in <math.h> and return double. Integer abs() lives in <stdlib.h> instead.

Lesson vs this index

The C Math page is the lesson: how to include math.h, link with -lm, use radians, and practice with examples. This page is the functions index—30 tutorials grouped by job. Open a row for syntax, examples, and FAQs for that one function.

What should beginners open first?

After the overview, start with fabs(), sqrt(), pow(), and sin(). Those cover absolute value, roots, powers, and basic trigonometry (after converting degrees to radians).

Need setup help?

Compile tips, radians, and five worked examples are on C Math—not repeated here.

Trig uses radians.

Convert first: rad = deg * M_PI / 180.0 before sin / cos / tan.

Pick the right abs.

abs() for int; fabs() for double.

C Syntax

Every math.h call follows the same pattern—include, call, link:

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

int main(void) {
    double root = sqrt(25.0);
    double power = pow(2.0, 10.0);

    printf("sqrt(25) = %.0f\n", root);
    printf("2^10     = %.0f\n", power);

    return 0;
}
/* gcc math_call.c -std=c11 -o math_call -lm */

Individual function pages show signatures, edge cases, and more examples. Use the tables below to jump to the right guide.

Choose a Function by Job

Not sure which tutorial to open? Match the job to a function:

JobPrefer
Distance / radiussqrt() or hypot()
Powers / growthpow(), exp()
Anglessin(), cos() after degree→radian
Quadrant-aware angleatan2() instead of atan()
Snap / gridsfloor(), ceil(), trunc()
Float compare tolerancefabs(a - b) < epsilon with fabs()
Integer magnitudeabs() from <stdlib.h>

Quick results cheat sheet

CallResult
sqrt(25.0)5.0
pow(2.0, 10.0)1024.0
sin(M_PI / 2.0)1.0 (90° in radians)
fabs(-3.14)3.14
floor(-2.7)-3.0 (toward −infinity)
trunc(-2.7)-2.0 (toward zero)
hypot(3.0, 4.0)5.0

Jump to a category

How to Browse This Index

A practical path through the C math function tutorials:

  1. If you still need -lm or radians, open the C Math lesson first.
  2. Use Choose a Function by Job when you know the task but not the name.
  3. Use the search box below when you already know the function name.
  4. Browse categories when you want related APIs (for example all rounding helpers).
  5. Open a tutorial for syntax, five examples, output, and FAQs—then return here for the next one.

C Math Functions Index

30 tutorials. Search by name or scroll the categories. Each row opens a full guide.

Absolute Value

2 functions

Remove the sign—integer abs() in stdlib.h and floating-point fabs() in math.h.

FunctionDescriptionTutorial
abs()Absolute value of int (stdlib.h).Try it
fabs()Absolute value of double.Try it

Roots & Powers

3 functions

Square roots, cube roots, and raise a number to any exponent.

FunctionDescriptionTutorial
sqrt()Square root of x.Try it
cbrt()Cube root of x.Try it
pow()x raised to the power y.Try it

Exponential & Logarithm

3 functions

Natural exponent, natural log, and base-10 log.

FunctionDescriptionTutorial
exp()e raised to the power x.Try it
log()Natural logarithm (base e).Try it
log10()Base-10 logarithm.Try it

Circular Trigonometry

7 functions

Sine, cosine, tangent, and inverses—angles in radians unless you convert from degrees.

FunctionDescriptionTutorial
sin()Sine of angle in radians.Try it
cos()Cosine of angle in radians.Try it
tan()Tangent; undefined when cos = 0.Try it
asin()Arcsine; result in radians.Try it
acos()Arccosine; result in radians.Try it
atan()Arctangent of one value.Try it
atan2()Angle from (y, x) in radians.Try it

Hyperbolic Functions

6 functions

sinh, cosh, tanh and inverses—not the same as circular trig despite similar names.

FunctionDescriptionTutorial
sinh()Hyperbolic sine.Try it
cosh()Hyperbolic cosine.Try it
tanh()Hyperbolic tangent; output in (-1, 1).Try it
asinh()Inverse hyperbolic sine.Try it
acosh()Inverse hyperbolic cosine.Try it
atanh()Inverse hyperbolic tangent.Try it

Rounding & Integer Parts

5 functions

Round up, down, to nearest, truncate toward zero, or split whole and fractional parts.

FunctionDescriptionTutorial
ceil()Round toward +infinity.Try it
floor()Round toward −infinity.Try it
round()Round to nearest integer.Try it
trunc()Truncate toward zero.Try it
modf()Split into whole and fraction.Try it

Remainder & Decomposition

4 functions

Floating remainder, mantissa/exponent, scale by powers of two, and hypotenuse length.

FunctionDescriptionTutorial
fmod()Floating-point remainder.Try it
frexp()Mantissa and exponent of x.Try it
ldexp()x times 2 raised to exp.Try it
hypot()sqrt(x² + y²) without overflow.Try it

Key Takeaways

  • This page is the catalog of every math function tutorial in the C series.
  • Start with fabs, sqrt, pow, and sin (radians).
  • Choose by job above when you know the task but not the function name.
  • Lesson first: C Math for -lm and examples; this index for lookup.

One line: Use this index to find the right math.h tutorial—search, choose by job, then open the guide.

Frequently Asked Questions

They are library routines—mostly in math.h—for floating-point work: roots, powers, logs, trigonometry, rounding, and remainders. You call them by name, such as sqrt(16.0) or sin(M_PI / 2).
C Math is the lesson: include math.h, link with -lm, use radians, and work through examples. This Math Functions page is the catalog—search and open each function’s full tutorial.
If you are new, read C Math first. In this index, open fabs(), sqrt(), pow(), and sin() next. Then pick rounding or more trig from the tables below.
On GCC and Clang, yes: gcc main.c -std=c11 -o main -lm. MSVC often links math automatically. Full compile notes live on the C Math overview.
No—radians. Convert with deg * M_PI / 180.0. See the C Math lesson and the sin() tutorial for worked examples.
Syntax, return value, five examples with output, notes, and FAQs for that one function. Use this index to jump to the right guide.

Start with fabs()

Open the floating absolute-value guide—syntax, examples, and a quick reference.

fabs() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

30 people found this page helpful