PDA

Click to See Complete Forum and Search --> : Calculator programs


Oct 27th, 2000, 07:25 PM
Does anyone have a sample calculator program i could look at?

Blitz
Oct 29th, 2000, 10:06 AM
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 :)

Silicon Valley
Oct 30th, 2000, 09:51 AM
This is a very simple and basic calculator I wrote in C for a homework assignment a while ago.

Maybee this helps.



#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");
}
}
}



P.S
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]

Nov 1st, 2000, 06:36 PM
Not very good, but I have a DOS based Calculator. E-mail me if you would like it.

rfo
Nov 2nd, 2000, 07:31 AM
I used a sample from the MSDN:

VB-KnowledgeBase, Example to Evaluate
Basic Numeric Expressions
Article ID: Q86688