Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Explain the syntax of switch…case statement. Write a program using switch…case statement. : GTU Nov-Dec 2010

#include
#include

void main()
{
    int no1,no2,choice;
    clrscr();
    printf("\n Please enter Number 1 : ");
    scanf("%d",&no1);
    printf("\n Please enter Number 2 : ");
    scanf("%d",&b);
    printf("Enter Choice : ");
    printf("\n1. Add");
    printf("\n2. Subtract");
    printf("\n3. Multiply");
    printf("\n4. Divide\n\n\t : ");
    scanf("%d",&choice);
 
    switch(choice)
    {
        case 1 :
            printf("Addition : %d",no1+no2);
            break;
        case 2 :
            printf("Subtraction : %d",no1-no2);
            break;
        case 3 :
            printf("Multiplication : %d",no1*no2);
            break;
        case 4 :
            printf("Divided : %d",no1/no2);
            break;
        default :
            printf("Your Choice is Wrong");
            break;
    }
    getch();
}


This post first appeared on Ask For Program, please read the originial post: here

Share the post

Explain the syntax of switch…case statement. Write a program using switch…case statement. : GTU Nov-Dec 2010

×

Subscribe to Ask For Program

Get updates delivered right to your inbox!

Thank you for your subscription

×