我已经编了以个简单运算,怎么在上面加一个取余运算,求帮助
#include <stdio.h>int main()
{
float data1, data2;
char op;
while (3 == scanf("%f%c%f", &data1, &op, &data2) )
{
float result;
printf("%.6lf%c%.6lf=", data1, op, data2);
switch (op)
{
case '+':
result = data1 + data2;
break;
case '-':
result = data1 - data2;
break;
case '*':
result = data1 * data2;
break;
case '/':
result = data1 / data2;
break;
default:;
}
printf("%.6lf\n", result);
}
return 0;
}
2.操作符增加和”%”,操作数增加非负浮点数(如2.0,816.73等)