Write a c program to addition, subtraction, multiplication, division and Modules by using two integers

Write a c program to addition, subtraction, multiplication, division and Modules by using two integers.

This C program performs basic arithmetic operations (addition, subtraction, multiplication, division, and modulus) on two integers. It prompts the user to enter two integer values, performs the calculations, and displays the results.


  • #include <stdio.h>: The standard input-output library is included for using functions like printf and scanf.
  • int N1, N2;: Declaration of two integer variables to store the input values.
  • printf(“Enter the first integer: “);: Prompt the user to enter the first integer.
  • scanf(“%d”, &N1);: Read the first integer entered by the user and store it in N1.
  • Similar steps are repeated for the second integer (N2).
  • Addition, subtraction, multiplication, division, and modulus operations are performed and results are displayed using printf.
  • Conditional checks are added to handle division by zero scenarios. If the user tries to divide by zero, appropriate error messages are displayed.


Arithmetic operators:

  • Addition : + ; Example: 4+2=6
  • Subtraction : – ; Example: 4-2=2
  • Multiplication : * ; Example: 4*2=8
  • Division : / ; Example: 4/2=2
  • Modulo : % ; Example: 4/2=0(reminder value)


#include <stdio.h>
int main() {
int N1,N2,sum,difference,product,modulo;
float quotient;
printf("Enter N1: ");
scanf("%d", &N1);
printf("Enter N2: ");
scanf("%d", &N2);
sum = N1+N2; //Addition//
difference = N1-N2;//subtraction//
product = N1*N2;//Multiplication//
quotient = (float)N1/N2;//division//
modulo = N1%N2; //modulo// 
printf("\nSum = %d", sum);
printf("\nDifference = %d", difference);
printf("\nMultiplication = %d", product);
printf("\nDivision = %.3f", quotient);
printf("\nRemainder = %d", modulo);
return 0;


Enter n1: 6 Enter n2: 3 Sum = 9 Difference = 3 Multiplication = 18 Division = 2.000 Remainder = 0

The program successfully takes two integers as input, performs the specified arithmetic operations, and displays the results on the console. It includes checks to handle potential division by zero scenarios.

Scroll to Top