[ back to toc ]

simulate a calculator

Date: 2002/05/24 13:53

Q:
In The name of ALLAH
hello peter
tanx for your answer .i wrote it :#include "stdio.h"
#include "conio.h"
void f1(void);
main(){
float a,b;int i=0;
char ch;
f1();
gotoxy(35,12);
scanf("%f",&a);
gotoxy(35,12);
while(ch!='='){
clrscr();
f1();
gotoxy(35,12);
ch=getche();
gotoxy(35,12);
switch(ch){
case '+':
gotoxy(35,12);
scanf("%f",&b);
gotoxy(35,12);
a+=b;
break;
case '-':
gotoxy(35,12);
scanf("%f",&b);
gotoxy(35,12);
a-=b;
break;
case '*':
gotoxy(35,12);
scanf("%f",&b);
gotoxy(35,12);
a*=b;
break;
case '/':
gotoxy(35,12);
scanf("%f",&b);
gotoxy(35,12);
a/=b;
break;

}

}
gotoxy(35,12);
printf("%0.2f\n",a);

getch();

}
void f1(void)
{
int i;

for (i=10;i<25;i++){ textcolor(2);
textbackground(12);gotoxy(10,1+i);cprintf("|");gotoxy(62,1+i);cprintf("|")
;} textcolor(7);textbackground(1);
gotoxy(10,10);cprintf("--");
gotoxy(10,15);cprintf("--");
gotoxy(10,20);cprintf("--");
gotoxy(10,25);cprintf("--");
textbackground(0);textcolor(5);gotoxy(13,12);printf("1");
gotoxy(22,12);printf("2"); gotoxy(31,12);printf("3");
gotoxy(13,17);printf("4"); gotoxy(22,17);printf("5");
gotoxy(31,17);printf("6");
gotoxy(13,23);printf("7"); gotoxy(22,23);printf("8");
gotoxy(31,23);printf("9");
gotoxy(40,23);printf("0");
gotoxy(33,12);cprintf("|");
gotoxy(33,11);cprintf("|");gotoxy(33,13);cprintf("|");gotoxy(33,14);cprint
f("|");
gotoxy(62,12);cprintf("|");
gotoxy(62,11);cprintf("|");gotoxy(62,13);cprintf("|");gotoxy(62,14);cprint
f("|");
gotoxy(40,17);printf("+");
gotoxy(50,17);printf("-");gotoxy(60,17);printf("*");
gotoxy(46,23);textcolor(3);printf("CALCULATOR");gotoxy(60,23);printf("/");

}

Can u help me about doing better my program?
tanx my expert.

A:
If you have some specific question I can answer that. However I have no
time to read through a program or debug it. To learn programming everibody
has to go through on his own mistakes and have hard time until learns
programming.

Why do you start each letter in the name of ALLAH?

Regards,
Peter

[ back to toc ]