code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
Terms of Agreement:
By using this code, you agree to the following terms...
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for langauges that allow it) freely and with no charge.
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame.
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
//
#include
#include
#include
void main(void)
{
float A,B,C;
clrscr();
gotoxy(22,2);
cprintf("Welcome to BASSAM CHAT Calculator");
gotoxy(21,1);
printf("***********************************");
gotoxy(32,3);printf("Version 3.0\n");
gotoxy(22,3);printf("*********");
gotoxy(44,3);printf("***********");
printf("\n\nUse the calculator and have fun...\n");
Again:
printf("\nPlease give the first number...\n");
scanf("%f",&A);
printf("The number I got is %.3f",A);
printf("\n\nNow what would you like to do with %.3f ?\n",A);
switch(getche())
{
case '+':
printf("\nOk, you may give the second number...\n");
scanf("%f", &B);
printf("I received the second number as %.3f\n",B);
C=A+B;
printf("\n\t\tAddition of %.3f and %.3f results in %.3f\n",A,B,C);
break;
case '-':
printf("\nSo what is the second number...\n");
scanf("%f", &B);
printf("Second number received is %.3f\n",B);
C=A-B;
printf("\n\t\tAfter subtracting %.3f from %.3f, %.3f is left over.\n",B,A,C);
break;
case '*':
printf("\nGive second number to multiply to %.3f...\n",A);
scanf("%f", &B);
printf("The second number is %.3f\n",B);
C=A*B;
printf("\n\t\tProduct of %.3f and %.3f gives %.3f\n",A,B,C);
break;
case '/':
printf("\nAllowed to provide the second number...\n");
scanf("%f", &B);
printf("Second number input is %.3f\n",B);
C=A/B;
printf("\n\t\tDividing %.3f by %.3f results in %.3f\n",A,B,C);
break;
case '%':
printf("\nWhat is the second number in your mind...\n");
scanf("%f", &B);
printf("Got second number as %.3f\n",B);
C=(A/B)*100;
printf("\n\t\t%.3f is %.3f percent of %.3f\n",A,C,B);
break;
case 's':
C=A*A;
printf("\n\t\tThe square of %.3f is %.3f\n",A,C);
break;
case 'x':
C=1/A;
printf("\n\t\tThe result of 1/%.3f %.3f\n",A,C);
break;
default:
printf("\nPlease do not misuse me...\n");
}
printf("\nPress SPACE for more calculation or any other key to quit me...\n");
if(getch() == ' ') goto Again;
}