sample problems
#include
float addition(double num1, double num2);
float subtraction(double num1, double num2);
float multiplication(double num1, double num2);
float division(double num1, double num2);
float modulo(int num1, int num2);
main()
{
double num1, num2;
clrscr();
printf("\n Enter first number: ");
scanf("%lf", &num1);
printf("\n Enter second number: ");
scanf("%lf", &num2);
printf("\n The sum of %.2lf and %.2lf is equal to %.2lf", num1, num2, addition(num1, num2));
printf("\n The difference of %.2lf and %.2lf is equal to %.2lf", num1, num2, subtraction(num1, num2));
printf("\n The product of %.2lf and %.2lf is equal to %.2lf", num1, num2, multiplication(num1, num2));
printf("\n The quotient of %.2lf and %.2lf is equal to %.2lf", num1, num2, division(num1, num2));
printf("\n The modulo of %.2lf and %.2lf is %.2lf", num1, num2, modulo(num1, num2));
getch();
}
float addition(double num1, double num2)
{
int sum;
sum=num1+num2;
return sum;
}
float subtraction(double num1, double num2)
{
int difference;
difference=num1-num2;
return difference;
}
float multiplication(double num1, double num2)
{
int product;
product=num1*num2;
return product;
}
float division(double num1, double num2)
{
int quotient;
quotient=num1/num2;
return quotient;
}
float modulo(int num1, int num2)
{
long modu;
modu=num1%num2;
return modu;
}
shorter version------------------
#include
float addition(double num1, double num2)
{
return (num1+num2);
}
float subtraction(double num1, double num2)
{
return (num1-num2);
}
float multiplication(double num1, double num2)
{
return (num1*num2);
}
float division(double num1, double num2)
{
return (num1/num2);
}
float modulo(int num1, int num2)
{
return (num1%num2);
}
main()
{
double num1, num2;
clrscr();
printf("\n Enter first number: ");
scanf("%lf", &num1);
printf("\n Enter second number: ");
scanf("%lf", &num2);
printf("\n The sum of %.2lf and %.2lf is equal to %.2lf", num1, num2, addition(num1, num2));
printf("\n The difference of %.2lf and %.2lf is equal to %.2lf", num1, num2, subtraction(num1, num2));
printf("\n The product of %.2lf and %.2lf is equal to %.2lf", num1, num2, multiplication(num1, num2));
printf("\n The quotient of %.2lf and %.2lf is equal to %.2lf", num1, num2, division(num1, num2));
printf("\n The modulo of %.2lf and %.2lf is %.2lf", num1, num2, modulo(num1, num2));
getch();
}