C programming

Saturday, January 17, 2009

#include #include void add(int a,int b) { textcolor(GREEN); cprintf("\nEnter twon numnbers: "); scanf("%d%d",&a,&b); int c=a+b; cprintf("%d + %d =%d",a,b,c); } void sub(int a,int b) { textcolor(RED); cprintf("\nEnter twon numnbers: "); scanf("%d%d",&a,&b); int c=a-b; cprintf("%d - %d =%d",a,b,c); } void main() { int a,b; clrscr(); int t=0; textcolor(BLUE); printf(" *********************"); textcolor(BLUE); printf("\n MENU \n"); textcolor(BLUE); printf("\nPress a for add :\n"); textcolor(BLUE); cprintf("\nPress s for subtract\n"); textcolor(RED); cprintf("\nPress e for exit\n"); textcolor(BLUE); cprintf("\npress any key to continue..........\n"); while(t==0) { printf("\n\n Please chose an operation between a,s,e :"); l: char c=getch(); switch(c) { case'a': add(a,b); break; case's': sub(a,b); break; case'e': t=1; break; default: goto l; } } }

0 comments:

Visitors

PlugIn.ws - Free Hit Counter, Web Site Statistics, Traffic Analysis

  © Blogger template Leaving by Ourblogtemplates.com 2008

Back to TOP