Make a simple C program to find the sum (addition), multiply, subtract, divide and remainder of two numbers. C program will be as follows –
/*C program to find remainder(modulus), sum, subtract, multiply and divide two numbers */ #include<stdio.h> void main() { int a,b,sum,sub,mul,rem; float division; printf("Enter any two numbers a and b to sum, subtract, multiply, divide and find remainder of these two numbers\n"); scanf("%d%d",&a,&b); sum=a+b; sub=a-b; mul=a*b; division=(float)a/b; rem=a%b; printf("\n Sum of %d and %d is \t %d",a,b,sum); printf("\n Subtraction of %d and %d is \t %d",a,b,sub); printf("\n Multiplication of %d and %d is \t %d",a,b,mul); printf("\n Division of %d and %d is \t %f",a,b,division); printf("\n remainder of %d and %d is \t %d",a,b,rem); getch(); }
Input – Enter any two numbers- 5 4
Output –
Sum is – 9
Subtraction – 1
Multiplication – 20
Division – 1.25
Modulus is 1
please……………. learn do you c me
What if a is any number and b is zerO?
please reply me im stuck on this problem…
If any number is zero then it will perform operations with zero only. It’s simple. Like an example –
a = 5 and b = 0
sum = 5
subtraction = 5
multiplication = 0
and so on…
Thank you
Thanks a lot for this tutorial. It is very useful for beginners like me.
I was looking for C program for addition subtraction multiply