C++ Calculator Skipping Else Statement

后端 未结 4 1063
伪装坚强ぢ
伪装坚强ぢ 2021-01-26 08:07

I was making a simple calculator in C++. However the program does not completely function the way it should. When run, the trig if statement executes fine, however, the basic ar

4条回答
  •  不要未来只要你来
    2021-01-26 08:24

    Since you want to do something different for each trig function, you should just have a single if...else if...else if...else if...else chain. There is no need to nest the if statements as you have. In fact, it is probably less efficient because you check each condition twice.

提交回复
热议问题