# Mathematical Operations in C

Discussion in 'C' started by lionaneesh, Jun 15, 2011.

1. ### lionaneeshActive Member

Joined:
Mar 21, 2010
Messages:
848
224
Trophy Points:
43
Occupation:
Student
Location:
India
In this tutorial we’ll be learning some mathematical operations in C (multiplications, divisions , additions , subtractions , modulus) So let’s get started

Almost all mathematical operations in C follow the following syntax :-

Code:
```[number] [operator] [number] …
```
The ‘…’ indicates that any number of terms (>2) can be operated in C.

Code:
```[Number] + [Number]
```
Eg :-

Code:
```1 + 2
```
Subtraction :-

Code:
```[Number] – [Number]
```
Multiplication :-

Code:
```[Number] * [Number]
```
Division:-

Code:
```[Number] / [Number]
```
Modulus:-

Code:
```[Number] % [Number]
```

Now that we know how to carry Different mathematical operations in C, So let’s now use this knowledge to do mathematical tasks (I suggest the readers to try out first before seeing the solutions)

1. Make a C program to print the sum of 3 and 5 on to the screen.
Code:
```#include<stdio.h>

int main()
{
int sum = 3 + 5;
printf("%d\n",sum);
return(0);
} ```
2. Make a C program to print out the product of 99 and 12345 on the screen
Code:
```#include<stdio.h>

int main()
{
int product = 99 * 12345;
printf("%d\n",product);
return(0);
}
```
3. Make a C program to print out the difference of 88 and 77 on the screen.
Code:
```#include<stdio.h>

int main()
{
int difference = 88 - 77;
printf("%d\n",difference);
return(0);
}
```
I hope you liked this tutorial , Stay tuned for more

2. ### jam143New Member

Joined:
Jul 1, 2011
Messages:
8
0
Trophy Points:
0
Occupation:
n/a
Location:
philippines
how about having other mathematical equations.. for example √ (this is square root) thank you.

3. ### lionaneeshActive Member

Joined:
Mar 21, 2010
Messages:
848
224
Trophy Points:
43
Occupation:
Student
Location:
India
C provides us a Set of Functions for dealing with under roots , squares , cubes etc. We'll deal with that in the later tutorials

4. ### jam143New Member

Joined:
Jul 1, 2011
Messages:
8
0
Trophy Points:
0
Occupation:
n/a
Location:
philippines
ahh.. okay I get it.. thank you.. 5. ### lionaneeshActive Member

Joined:
Mar 21, 2010
Messages:
848
224
Trophy Points:
43
Occupation:
Student
Location:
India
My Pleasure !

Joined:
Nov 5, 2011
Messages:
2