ok im having a little problem here
im trying to make a simple calculator in C, but everytime i run it and press enter for the first value, i get an error and it closes. here is the source code. please tell me if i messed up on something. Im very new to C and a little help would be great.
Code:
#include<stdio.h>
int main()
{
float operation;
float x;
float y;
float answer;
printf(" Type 1 for addition, 2 for multiplication, 3 for subtraction, or 4 for division\n");
printf(" Then type the two numbers.\n");
scanf("%s",operation);
scanf("%f",x);
scanf("%f",y);
if(operation==1)
{
answer=x + y;
}
else if(operation==2)
{
answer=x * y;
}
else if(operation==3)
{
answer=x - y;
}
else
{
answer=x / y;
}
printf(" The answer is %f!\n",answer);
getchar();
return 0;
}