C has a full range of arithmetic operators: /, *, %, +, -. You can use character input to read the operators, floating-point input to read the numbers, and then use comparisons to determine the operations. Here is a severely crippled example of one way to go about it:
Code:
#include <stdio.h>
int main ( void )
{
double a, b, c;
char o1, o2;
printf ( "Enter an infix expression: a op b op c: " );
if ( scanf ( "%lf %c %lf %c %lf", &a, &o1, &b, &o2, &c ) == 5 ) {
double result = 0.0;
/* First part, assume only high precedence operations */
switch ( o1 ) {
case '/': result = a / b; break;
case '*': result = a * b; break;
}
/* Second part, any operation valid */
switch ( o2 ) {
case '/': result /= c; break;
case '*': result *= c; break;
case '+': result += c; break;
case '-': result -= c; break;
}
printf ( "(%.0f%c%.0f)%c%.0f = %f\n", a, o1, b, o2, c, result );
}
return 0;
}