c programing problem, pls check my mistakes

2008-02-07 7:09 am
I am new in c programing...
i write a simple c program, but it doesn't work.
Could any one help me, pls?
pls help me to check where are my mistakes. Thanks a lot.

---------------------------------------------------------------------------------------

the code: http://www1.uwants.com/viewthread.php?tid=5725901&extra=page%3D1

i can't post them here....
pls check them by clicking the link above

回答 (1)

2008-02-07 7:55 pm
✔ 最佳答案
Basically your program has a sound logic, and it actually works after making two minor corrections.
Namely, the continue statements should be enclosed in braces {} with the previous statement, such as:

if (operand1 < = 0) { printf("the entry was incorrect for operand1"); continue; }
and later
if (operand2 < = 0) { printf("the entry was incorrect"); continue; }
so that the continue statement does not get executed even if the operands are greater than zero.

If you have time for more exercise, I would suggest you check the operators entered by the user, so that if the user enters an illegal operator, it will give a message.

Keep up the good work.


收錄日期: 2021-04-13 15:06:18
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20080206000051KK03187

檢視 Wayback Machine 備份