☜
☞
Math Functions
There are several ways to perform math operations in C. The C language provides a number of built-in operators and functions for performing mathematical calculations, such as addition, subtraction, multiplication, division, and modulus.
Here are some examples of using mathematical operators in C:
#include <stdio.h>
int main()
{
int a = 5;
int b = 3;
int c;
c = a + b; // addition
printf("%d + %d = %d\n", a, b, c);
c = a - b; // subtraction
printf("%d - %d = %d\n", a, b, c);
c = a * b; // multiplication
printf("%d * %d = %d\n", a, b, c);
c = a / b; // division
printf("%d / %d = %d\n", a, b, c);
c = a % b; // modulus
printf("%d %% %d = %d\n", a, b, c);
return 0;
}
In this example, we have performed several basic math operations using the built-in operators. The + operator is used for addition, the - operator is used for subtraction, the * operator is used for multiplication, the / operator is used for division,
☜
☞