C program using switch-case

 #include <stdio.h>

int main() 

{

    int a, b, choice;


    printf("Enter two numbers: ");

    scanf("%d %d", &a, &b);


    printf("\n1. Addition");

    printf("\n2. Subtraction");

    printf("\n3. Multiplication");

    printf("\n4. Division");


    printf("\nEnter your choice: ");

    scanf("%d", &choice);


    switch(choice)

    {

        case 1:

            printf("Sum = %d", a + b);

            break;


        case 2:

            printf("Difference = %d", a - b);

            break;


        case 3:

            printf("Product = %d", a * b);

            break;


        case 4:

            printf("Quotient = %d", a / b);

            break;


        default:

            printf("Invalid choice");

    }

}

Comments

Popular posts from this blog

Single Program Using All Automatic String Functions

C program for subtraction of two matrices (2D Arrays)

C program for Multiplication of Two matrices