Commit 5347fc53 by emonyi

Upload New File

parent 75dd7529
Showing with 92 additions and 0 deletions
#include <stdio.h>
#include <conio.h>
#include <math.h>
int add(int a, int b);
int subt(int c, int d);
int mult(int e, int f);
float div(float g, float h);
int main()
{
int x;
int y;
int sum;
int difference;
int product;
float quotient;
printf("Enter two integers:");
scanf("%d\n", &x);
scanf("%d", &y);
int choice;
printf("select a calculation 1 to add, 2 to subtract, 3 to multiply, 4 to divide: ");
scanf("%d",&choice);
switch(choice)
{
case 1:
sum = add(x, y);
printf("%d", sum);
break;
case 2:
difference = subt(x, y);
printf("%d", difference);
break;
case 3:
product = mult(x, y);
printf("%d", product);
break;
case 4:
quotient = div(x, y);
printf("%f", quotient);
break;
default:
printf("invalid! \n out of bounds!! ");
break;
}
return 0;
}
int add(int a, int b)
{
int output;
output = a + b;
return output;
}
int subt(int c, int d)
{
int output;
output = c - d;
return output;
}
int mult(int e, int f)
{
int output;
output = e * f;
return output;
}
float div(float g, float h)
{
float output;
output = g / h;
return output;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment