Arithmetic Operators in C | Types of Arithmetic Operators in C

In this tutorial, You learn how to write C program for arithmetic operators?. 

Write a c program to input the two numbers from the user and perform operations on operands. 

Types of Arithmetic Operators in C

  1. Addition 
  2. Subtraction
  3. Multiplication
  4. Division
  5. Modulus 
arithmetic operators in c

You have doubt in the above paragraph then I shared a table below which clear your all doubts and it helps to understand about operators.

Arithmetic Operators Operation Example 
                + Addition 15 + 3 = 18
 Subtraction 15 - 3 = 12
                  Multiplication  15 * 3 = 45
                 / Divison 15 / 3 = 5
                 % Modulus 15 % 3 = 0 

Some of them know about the difference in division and modulus but we revisit this. Now when we use division(/) operator with operands then it gives results as quotient and when we use modulus(%) operator with operands then the result is remainder. Example as mention above table.

Now you have great knowledge about the arithmetic operators and from examples of the above table you understand the logic and now in the below c program, we use the same logic.

int main()
   int a,b;
    printf(" \n Enter two numbers");
    printf("\n Addition of a and b: %d \t",(a+b));
    printf("\n Subtraction of a and b: %d \t",(a-b));
    printf("\n Multiplication of a and b: %d \t",(a*b));
    printf("\n Divide of a and b: %d \t",(a/b));
    printf("\n Modulus of a and b: %d \t",(a%b));
   return 0;

The program asks the user for two numbers and then to perform arithmetic operations on numbers.

   Enter Two Numbers 15 3 
   Addition of a and b: 18
   Subtraction of a and b: 12
   Multiplication of a and b: 45
   Division of a and b: 5
   Modulus of a and b: 0

You have any problem with these 
arithmetic operators in C. and also do Operations in C. Do not hesitate and write your problem in the comment box. I will support your problem.

Happy Coding 😊

No comments:

If you have any doubts, Please let me know

Powered by Blogger.