Arithmetic Operators in C - Operations in C

In this tutorial, we learn how to write C Program for arithmetic operators?. We will write the C Program to arithmetic operators. Write a c program to input the two numbers from the user and perform operations on operands i.e. these operators are work with two numbers and these numbers are known as operands. Operators like Addition, Subtraction, Multiplication, Divide, and Modulus on two integer operands. How to perform operations on operands in c programming. Logic to perform operations.

arithmetic operators in c - operations in c
Arithmetic Operators


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.

Arithmetic Operators in C

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.

C Program

#include<stdio.h>  
int main()
 { 
   int a,b;
    printf(" \n Enter two numbers");
    scanf("%d%d",&a,&b);
    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;
 }

Output

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 this C
 Program for arithmetic operators. 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.