Thursday, February 12, 2009

Exercise 3

Output:


A-D




E


#include
#include


void main(){
clrscr();
int choice,a,b,n,y,sum=0,sub=0,mul=0,div=0;

gotoxy(30,4);textcolor(GREEN);cprintf("W E L C O M E ! ! !");


gotoxy(26,6);textcolor(LIGHTCYAN);cprintf("\nSelect operation you like to Try!");
gotoxy(25,8);textcolor(RED);cprintf("\n\t[A] for ADDITION");
gotoxy(25,9);textcolor(LIGHTRED);cprintf("\n\t[B] for SUBTRACTION");
gotoxy(25,10);textcolor(RED);cprintf("\n\t[C] for MULTIPLICATION");
gotoxy(25,11);textcolor(LIGHTRED);cprintf("\n\t[D] for DIVISION");
gotoxy(25,12);textcolor(RED);cprintf("\n\t[E] for Exit");
gotoxy(25,14);textcolor(LIGHTCYAN);cprintf("\nEnter your choice operation here:");
scanf("%s",&choice);
switch(choice)
{
case 'A':
gotoxy(25,16);textcolor(BLUE);cprintf("Enter number:");
scanf("%d",&a);
gotoxy(25,17);textcolor(RED);cprintf("Enter another number:");
scanf("%d",&b);
sum=a+b;
gotoxy(25,18);textcolor(GREEN);cprintf("Sum of two numbe is: %d",sum);
gotoxy(25,19);textcolor(CYAN);cprintf("Nice onE!!");
break;
}
switch(choice)
{
case 'B':
gotoxy(25,16);textcolor(BLUE);cprintf("Enter number:");
scanf("%d",&a);
gotoxy(25,17);textcolor(RED);cprintf("Enter another number:");
scanf("%d",&b);
sub=a-b;
gotoxy(25,18);textcolor(GREEN);cprintf("Sub of two numbe is: %d",sub);
gotoxy(25,19);textcolor(CYAN);cprintf("Nice onE!!");
break;
}
switch(choice)
{
case 'C':
gotoxy(25,16);textcolor(BLUE);cprintf("Enter number:");
scanf("%d",&a);
gotoxy(25,17);textcolor(RED);cprintf("Enter another number:");
scanf("%d",&b);
mul=a*b;
gotoxy(25,18);textcolor(GREEN);cprintf("Mul of two numbe is: %d",mul);
gotoxy(25,19);textcolor(CYAN);cprintf("Nice onE!!");
break;
}
switch(choice)
{
case 'D':
gotoxy(25,16);textcolor(BLUE);cprintf("Enter number:");
scanf("%d",&a);
gotoxy(25,17);textcolor(RED);cprintf("Enter another number:");
scanf("%d",&b);
div=a/b;
gotoxy(25,18);textcolor(GREEN);cprintf("Div of two numbe is: %d",div);
gotoxy(25,19);textcolor(CYAN);cprintf("Nice onE!!");
break;
}
switch(choice)
{
case'E':
gotoxy(25,18);textcolor(YELLOW);cprintf("\n\nEnd of the program,Thank you very much!! ^_^");
printf("\n\n\t\t\t\t\tBy: Lady");
}
getch();
}

No comments: