Home » Menu driven program for +,- ,*,/ and swap of two integer numbers.

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);

}

 

OUTPUT:

3

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s