I am writing a small algebra io program for an intro to c class and i am stuck. The idea is to get the user to input (a * b) + (c / d) + (e % f), in exactly the same format as you see it with the exception of using int values for the letters. I am using DevC++ form bloodshed (currently no longer on the web), and their program is getting the math wrong for the first operation. say i put in
(5 * 5) it tells me that it is 5 * 36
Here is my code so far:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
printf("Enter equation exactly as you see, inserting an INT for a, b, and c\n(a * b): \n");
scanf("%c ,%d ,%c ,%d ,%c",&a,&myVarA,&c,&myVarB,&e);
mySum1=myVarA*myVarB;
printf("%d * %d = %d",myVarA,myVarB,mySum1);
system("pause");
scanf("%*c");
return 0;[/ICODE]
}
So i am stuck and this is only the first out of 3 operations and the 1st out of three operations it has to do. i have sat in the tutoring lab at school and the tutors are stumped. Just for the reference here is the statement from the assignment:
(a * a) + (a / b) + (c % a)
- a, b, and c are INT values chosen by the user
- The user must enter the expression with the exact parentheses, spaces, and operators shown
- The user may enter any valid values for the variables
- The result is an INT value