Home » Sometech » Write a menu driven program for +,- ,*,/ and swap of two integer numbers.

Write a menu driven program for +,- ,*,/ and swap of two integer numbers.

#include <stdio.h>

#include <conio.h>

void main()

{

         float a,b,c;

         int choice;

         clrscr();

         printf(“\nEnter the value of a and b: “);

         scanf(“%f%f”,&a,&b);

        printf(“\n*********************”);

        

         printf(“\n* 1. Swap           *”);

         printf(“\n* 2. Addition       *”);

         printf(“\n* 3. Subtraction    *”);

         printf(“\n* 4. Multiplication *”);

         printf(“\n* 5. Division       *”);

         printf(“\n* 6. Exit           *”);

         printf(“\n*********************”);

    do

{        

         printf(“\n\nEnter choice ->”);

         scanf(“%d”,&choice);

         switch(choice)

{      

         case 1:  

                      c=a;

                        a=b;

                        b=c;

             printf(“\nAfter Swap =%f\n”,a,b);

             break;

        case 2: printf(“\nAddition = %f”,(a+b));

                   break;

        case 3: printf(“\nSubtraction = %f”,(a-b));

                   break;

        case 4: printf(“\nMultiplication = %f”,(a*b));

                      break;

        case 5: printf(“\nDivision = %f”,(a/b));

                      break;

        case 6: exit();

default:    

         printf(“\nChoice is wrong!!!”);

        getch();

 }

}

       while(choice<=6);

}

Advertisements

SoME Tech

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

%d bloggers like this: