Does anyone have a sample calculator program i could look at?
Printable View
Does anyone have a sample calculator program i could look at?
I did a calculator program using MFC too just that it only supports the 4 operations and can perform on 2 numbers only.
If you want, I can email to you the program :)
This is a very simple and basic calculator I wrote in C for a homework assignment a while ago.
Maybee this helps.
P.SCode:
#include <stdio.h>
#include <conio.h>
void main(void)
{
float num1=1.0, num2=1.0;
char op;
while(!(num1==0.0 && num2==0.0) )
{
printf("\n\nEnter in Number, operator, and number: ");
scanf("%f %c %f", &num1, &op, &num2);
switch(op)
{
case '+':
printf(" = %f", num1 + num2);
break;
case '-':
printf(" = %f", num1 - num2);
break;
case '*':
printf(" = %f", num1 * num2);
break;
case '/':
printf(" = %f", num1 / num2);
break;
default:
printf("Unknown operator");
}
}
}
Can someone also tell me how to make this tabbed and indented properly.
Thank you
[Edited by silicon valley on 11-09-2000 at 06:28 PM]
Not very good, but I have a DOS based Calculator. E-mail me if you would like it.
I used a sample from the MSDN:
VB-KnowledgeBase, Example to Evaluate
Basic Numeric Expressions
Article ID: Q86688