Learn C ProgrammingLearn ProgrammingPrograms On Case Control StructureResources

059. Write a Program to accept two numbers and a operator (+, -, *, / from user and complete that particular operation only in C language

By September 18, 2012 February 5th, 2018 No Comments
#include<stdio.h>
#include<conio.h>  
main()
{
	int n,rem,a,b;
	char op;
	clrscr();
	printf("Enter Operator(+,-,*,/)...");
	scanf("%c",&op);
	printf("Enter numbers...");
	scanf("%d%d",&a,&b);
	switch(op)
	{
	case '+' : printf("Result : %d ",a+b);break;
	case '-' : printf("Result : %d ",a-b);break;
	case '*' : printf("Result : %d ",a*b);break;
	case '/' : printf("Result : %d ",a/b);break;
	default  : printf("Invalid operator....");
	}
	getch();
}


Leave a Reply

DEMO01