0 votes
338 views
in C programming by (98.9k points)
edited
C Program for Addition, Subtraction, Multiplication, Division and Modulus of Two Numbers

1 Answer

0 votes
by (98.9k points)
selected by
 
Best answer
#include <stdio.h>
#include <conio.h>
 
int main(){
     
    int firstNumber, secondNumber;
    int sum, difference, product, modulo;
    float quotient;
    printf("Enter First Number: ");
    scanf("%d", &firstNumber);
    printf("Enter Second Number: ");
    scanf("%d", &secondNumber);
     
    //Adding two numbers 
    sum = firstNumber + secondNumber;
    // Subtracting two numbers
    difference = firstNumber - secondNumber;
    // Multiplying two numbers
    product = firstNumber * secondNumber;
    // Dividing two numbers by typecasting one operand to float
    quotient = (float)firstNumber / secondNumber;
    //returns remainder of after an integer division 
    modulo = firstNumber % secondNumber;
     
    printf("\nSum = %d", sum);
    printf("\nDifference  = %d", difference);
    printf("\nMultiplication = %d", product);
    printf("\nDivision = %.3f", quotient);
    printf("\nRemainder = %d", modulo);
     
    getch();
    return 0;
}

 

Related questions

0 votes
1 answer 978 views
asked Jul 20, 2022 in C programming by Doubtly (98.9k points)
0 votes
1 answer 157 views
0 votes
1 answer 134 views
0 votes
1 answer 127 views
0 votes
1 answer 179 views
asked Jul 20, 2022 in C programming by Doubtly (98.9k points)
0 votes
1 answer 161 views
asked Jul 20, 2022 in C programming by Doubtly (98.9k points)

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

563 users

...