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

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)

Basics:

Program:
#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;
}

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

No Comments

Post a Reply