Write a C Program to enter two numbers and perform all arithmetic operations - Basic C Programs



 

Write a C Program to enter two numbers and perform all arithmetic operations


Objective:

Write a C program to input two numbers and perform all arithmetic operations. How to perform all arithmetic operation between two numbers in C programming. C program to find sum, difference, product, quotient and modulus of two given numbers.


Example



Input:
First number: 10
Second number: 5


Output:

Sum = 15
Difference = 5
Product = 50
Quotient = 2
Modulus = 0


Solution Code:

//C program to perform all arithmetic operations by CodexRitik #include <stdio.h> int main() { int num1, num2; int sum, sub, mult, mod; float div; //Input two numbers from user printf("Enter any two numbers: "); scanf("%d%d", &num1, &num2); //Perform all arithmetic operations sum = num1 + num2; sub = num1 - num2; mult = num1 * num2; div = (float)num1 / num2; //here we are using type casting for float division mod = num1 % num2; //Print result of all arithmetic operations printf("SUM = %d\n", sum); printf("DIFFERENCE = %d\n", sub); printf("PRODUCT = %d\n", mult); printf("QUOTIENT = %f\n", div); printf("MODULUS = %d", mod); return 0; }



Note:

This Code is Verified by CodexRitik.If any error occurs then Comment correct code Below in comment box.

Disclaimer:-

The above hole problem solution is generated by the CodexRitik . if any of the query regarding this post or website fill the following contact form Thank You.

Write a C Program to enter two numbers and perform all arithmetic operations - Basic C Programs Write a C Program to enter two numbers and perform all arithmetic operations - Basic C Programs Reviewed by CodexRitik on January 03, 2021 Rating: 5

No comments:

Powered by Blogger.