
October 21st, 2012, 03:32 AM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 1
Time spent in forums: 56 m 15 sec
Reputation Power: 0
|
|
|
[Help]Calculator
I'm still new to C programming
i tried many times but the result still can't same as the question want.
the question is , make a calculator with the function of operators + - * / ^ and it require the use of selection and looping statement. The program will allow the operation of the operator functions more than once, and it will quit when recieves the character 'q' or 'Q'. the program then displays the last result for the calculation.
someone can show me which part was incorrect? Thank
PHP Code:
void scan_data(char *op1p, double *num1p);
void do_next_op(char op1, double num1, double *accum);
void main()
{
double num1;
char op1;
double accum;
accum=0;
printf("Hit enter to turn the calculator on");
getchar();
do{
scan_data(&op1, &num1);
do_next_op(op1, num1, &accum);
}
while
(!(op1 == 'q'));
return(0);
}
void scan_data(char *op1p, double *num1p)
{
printf("\nEnter an operator [^,*,/,+,-,q (quit): ");
scanf("%c",&op1p);
printf("\nEnter a number to calculate for: ");
scanf("%f",&num1p);
printf("The result so far is %c %f \n", &op1p, &num1p);
}
.
.
.
.
|