O.k i searched the site but didn't find anything related to my problem.
all ive done is made a simple calculator using the "else if" command.
I'll post my coding and compiler errors below.
#include <stdio.h>
main()
{
int valid =0;
char operator;
float number1,number2,sum;
printf("calculator\n");
printf("number\t operator\t number");
scanf("%f\t %c\t %f\t", &number1, &operator, &number2);
if(operator == '+')
sum = number1 '+' number2;
else if(operator =='-')
sum = number1 '-' number2;
else if(operator =='/')
sum = number1 '/' number2;
else if(operator == '*')
sum = number1 '*' number2;
else
valid = 1;
if(valid != 1)
printf("%f %c %f = %f", number1, operator, number2, sum);
else
printf("invalid command unlucky");
}
compile errors are as follows :
Error E2379 keelan.c 15: Statement missing ; in function main
Error E2379 keelan.c 17: Statement missing ; in function main
Error E2379 keelan.c 19: Statement missing ; in function main
Error E2379 keelan.c 21: Statement missing ; in function main
Warning W8070 keelan.c 30: Function should return a value in function main
*** 4 errors in Compile ***
now to my knowledge the: else for, for or while command don't use ; as a close.
as you can see I'm new to programming so don't be to harsh please.
thanks.