Commit 1e96b564 by viakul

Upload New File

parent 8b924c75
Showing with 68 additions and 0 deletions
#include <stdio.h>
float add(int x, int y);
float substract(int x, int y);
float mult(int x, int y);
float division(float x, float y);
int main()
{
int choice,a,b;
float result;
puts("pick first number");
scanf("%d", &a);
puts("pick second number");
scanf("%d", &b);
puts("What do you want to do with numbers?");
puts("for addition write 1 ");
puts("for division write 2 ");
puts("for subtraction write 3 ");
puts("for multiplication write 4 ");
do{
puts("make a choice ");
scanf("%d", &choice);
}while(choice < 1 || choice > 4);
switch(choice){
case 1:
result=add(a,b);
break;
case 2:
if ( b==0 ){
printf("it is impossible to divide by zero");
}else{
result=division(a, b);
}
break;
case 3:
result=substract(a, b);
break;
case 4:
result=mult(a,b);
break;
}
printf("%f",result);
return 0;
}
float add(int x, int y){
return(x+y);
}
float substract(int x, int y){
return(x-y);
}
float mult(int x, int y){
return(x*y);
}
float division(float x, float y){
return(x/y);
}
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