What I need to do is make a program that takes a number less than 6 digits that is inputed by the user and then solve according to the op inputed.
I just need to know how to get the reverse of the number the user enters without asking for the reverse.
My second question is: is it legal to use a while statement like this?
while(op == + || - || * || /)
This is the code I have so far. If you see any other problems feel free to correct. Thanks!
Code:
#include <stdio.h>
int main(void)
{
float num, sum, reverse;
char op;
printf("This program solves a five digit of smaller number and it reveresed.");
printf("Press any key to exit.");
while(op == + || - || * || /)
{
printf("Enter the operator you wish to use (+, -, /, *): ");
scanf(" %c", &op);
printf("Enter a 5 or less digit number: ");
scanf(" %f", &num);
reverse = ;
if (op == '+')
sum = num + reverse;
printf(" %f", sum);
if (op == '-')
sum = num - reverse;
printf(" %f", sum);
if (op == '*')
sum = num * reverse;
printf(" %f", sum);
if (op == '/')
sum = num / reverse;
printf(" %f", sum);
}
getchar();
getchar();
return 0;
}