I know this is probably a really dumb error on my part but I just started learning C. I wanted to make a basic calculator and I keep getting errors about the program expecting a const char * but I have a float. Also it says the last printf command (line 50 i believe) doesn't have the right syntax or correct form. Again I am really new so sorry for the incovinience. Thank you for all the help! My code is below.
#include <stdio.h>
#include <math.h>
int main()
{
char firstnum, secondnum, answer;
char function;
printf("Hello and welcome to my calculator!");
printf("Please input the function you would like to use");
scanf("%c", &function);
printf("Now please input the two variables.");
scanf("%f", &firstnum);
scanf("%f", &secondnum);
if (function == '+')
{
answer = firstnum+secondnum;
}
else if (function == '-')
{
answer = firstnum-secondnum;
}
else if (function == '*')
{
answer = firstnum*secondnum;
}
else if (function == '/')
{
answer = firstnum/secondnum;
}
else
{
printf("Sorry that was an incorrect function. The correct inputs are +, -, *, /.");
}
printf(answer);
return 0;
}