编程计算器,用C语言编写一个简单的计算器1
摘要#include<stdio.h> int main() { double num1 = 0; //输入1 double num2 = 0; //输入2 char ch
#include<stdio.h>
int main() {
double num1 = 0; //输入1
double num2 = 0; //输入2
char ch; //操作
double ret = 0; //结果 printf( “输入第一个数:” );
scanf( “%lf”, &num1 );
printf( “输入第二个数:” );
scanf( “%lf”, &num2 );
printf( “操作[+ – * /]:” );
getchar();
scanf( “%c”, &ch ); switch( ch ) {
case ‘+’:
ret = num1 + num2;
break;
case ‘-‘:
ret = num1 – num2;
break;
case ‘*’:
ret = num1 * num2;
break;
case ‘/’:
ret = num1 / num2;
break;
default:
break;
}
printf( “结果:%.2lf/n”, ret ); return 0;
} 写个简单易懂的编程计算器,你操作计算器的步骤就是编写程序的思路呀