Arithmetic Operation



            main()  
            {  
                int a, b, c;  
                clrscr();  
            
                printf("Enter the value of a: ");  
                scanf("%d", &a);  
            
                printf("\nEnter the value of b: ");  
                scanf("%d", &b);  
            
                printf("\nEnter your choice (1-Addition, 2-Subtraction, 3-Multiplication, 4-Division): ");  
                scanf("%d", &c);  
            
                switch(c)  
                {  
                    case 1:  
                        c = a + b;  
                        printf("\nAnswer is %d", c);  
                        break;  
            
                    case 2:  
                        c = a - b;  
                        printf("\nAnswer is %d", c);  
                        break;  
            
                    case 3:  
                        c = a * b;  
                        printf("\nAnswer is %d", c);  
                        break;  
            
                    case 4:  
                        if (b != 0)  
                        {  
                            c = a / b;  
                            printf("\nAnswer is %d", c);  
                        }  
                        else  
                        {  
                            printf("\nError: Division by zero is not allowed.");  
                        }  
                        break;  
            
                    default:  
                        printf("\nInvalid choice, operation does not exist.");  
                }  
            
                getch();  
            }  
            

Output: