I am not sure who else is enjoying my programming posts, but I am having fun re-exploring them again 🙂
In this post, we will see the different operators in ‘C’ and how to use them in a program.
The four major mathematical operators are addition, subtraction, multiplication and division and they are represented by these symbols:
a. + -> for addition
b. – -> for subtraction
c. / ->for division
d. * -> for multiplication
e. % -> to get the remainder when dividing

As an example,
10%5 will give ‘0’ and
10/5 will give 2
Let us see these mathematical operators in a ‘C’ program. You can try these programs in the online ‘C’ compiler from this page:
// Online C compiler to run C program online
#include <stdio.h>
int main() {
// Write C code here
printf("Doing the different mathematical operations with C\n");
int i, j, k;
printf("Enter the two numbers\n");
scanf("%d %d", &i, &j);
printf("The sum of two numbers is %d\n", i+j);
printf("The difference of two numbers is %d\n", i-j);
printf("The product of two numbers is %d\n", i*j);
printf("The quotient when dividing two numbers is %d\n", i/j);
printf("The remainder when dividing two numbers is %d", i%j);
return 0;
}
When the above program is compiled and run, you will get the following answer:
Doing the different mathematical operations with C
Enter the two numbers
10
5
The sum of two numbers is 15
The difference of two numbers is 5
The product of two numbers is 50
The quotient when dividing two numbers is 2
The remainder when dividing two numbers is 0
=== Code Execution Successful ===
In addition to these operators, there are relational operators(<, >, <=, >=, ==, !=), logical operators(&&, ||, !), bitwise operators, assignment operators.
We will explore more of what to do with these operators in the next ‘C’ post.
This post is the next post for BlogchatterHalfMarathon challenge by @blogchatter