0

New to C and am attempting to make a Calculator for a homework assignment. However, I am running into some problems

So far I have only attempting testing the add option but am still coming up with an Input/Output error when attempting to do so.

I am attempting to make a calculator that looks something like this:

Enter Number One:
Enter Number Two:
1-Add
2-Subtract
3-Multiply
4-Divide
5-Mod
Enter your choice: 

Result=
int choice, result;
float x,y ;
int main() {
    printf("Enter Number One:",&x);
    scanf("%f",&x);
    printf("Enter Number Two:",&y);
    scanf("%f",&y);

    printf("1-Add\n2-Subtract\n3-Multiply\n4-Divide\n5-Mod\n");
    printf("Enter your choice:",&choice);
    scanf("%d",&choice);
    if (choice==1) { 
        result=x+y;
        printf("Result=\n%f+%f=%f",x,y,result);
    }
}
Enter Number One:1
Enter Number Two:2
1-Add
2-Subtract
3-Multiply
4-Divide
5-Mod
Enter your choice:1
Result=
0.000000+0.000000=0.000000read from master failed
                                             : Input/output error

RUN FAILED (exit value 1, total time: 1s)
Tim
  • 2,510
  • 1
  • 22
  • 26
  • What operating system are you using? – Tim Sep 18 '19 at 02:26
  • 2
    See [Why should I always enable compiler warnings?](https://stackoverflow.com/questions/57842756/why-should-i-always-enable-compiler-warnings) – n. m. could be an AI Sep 18 '19 at 06:53
  • `printf("Enter Number One:",&x);` why is there an `&` before the variable in `printf`? (they are only used with `scanf` to get the address of the variable as `scanf` requires a *pointer* as the argument to fill. – David C. Rankin Sep 18 '19 at 07:01

0 Answers0