C语言之分支选择结构的应用之四则运算
#include <stdio.h> void main() { int a; int c,d; printf(" 1:+\n 2:- \n 3:*\n 4:/ \n"); printf("enter control\n"); scanf("%d",&a); printf("enter num1 and num2\n"); scanf("%d%d",&c,&d); switch (a) { case 1: c=c+d; printf("the result is %d\n",c); break; case 2: c=c-d; printf("the result is %d\n",c); break; case 3: c=c*d; printf("the result is %d\n",c); break; case 4: c=c/d; printf("the result is %d\n",c); break; default : printf ("the enter is fault"); } }