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

#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

Your email address will not be published. Required fields are marked *