Your IP : 216.73.216.40


Current Path : /var/www/html/bibhas.ghoshal/ITP_2019/lab/
Upload File :
Current File : /var/www/html/bibhas.ghoshal/ITP_2019/lab/prog14.c

#include <stdio.h>
int main(void)
{
	int operator;
	float left_operand, right_operand;

	while (1) {	/* Infinite loop */
		printf("Enter left operand: ");
		scanf("%f", & left_operand);
		printf("Enter right operand: ");
		scanf("%f", & right_operand);
		printf("1.'+' 2. '-' 3. '*' 4. '/' 5. '%%' \n");
		printf("Enter a valid number for operator: ");
		scanf("%d", &operator);

		switch (operator) {
			case 1: printf("%f\n", left_operand + right_operand);
			break;
			case 2: printf("%f\n", left_operand - right_operand);
			break;
			case 3: printf("%f\n", left_operand * right_operand);
			break;
			case 4: printf("%f\n", left_operand / right_operand);
			break;
			case 5: printf("%d\n", (int) left_operand % (int) right_operand);
			break;
			default: printf("Illegal operator\n");
			}
		return 0;
		}
}