C语言之分支选择结构的应用之四则运算

#include <stdio.h>
void main()
{   int a;
    int c,d;
	printf(" 1:+
 2:- 
 3:*
 4:/ 
");
    printf("enter control
");
	scanf("%d",&a);
		printf("enter num1 and num2
");
		scanf("%d%d",&c,&d);
	switch (a)
	{
	case 1: 
		c=c+d;
		printf("the result is %d
",c);
		break;
	case 2:
		
		c=c-d;
		printf("the result is %d
",c);
		break;
	case 3:
	
		c=c*d;
		printf("the result is %d
",c);
		break;
	case 4:
		c=c/d;
		printf("the result is %d
",c);
		break;
	default :
		printf ("the enter is fault");
		
	}
}

  

原文地址:https://www.cnblogs.com/switch-and-for/p/3390154.html