You are here:

C++/C++ program

Advertisement


Question
Your Question was:

Hello,

I need help debugging my C++ code. It's fairly simple, it's about do-while loops.

Here is the link where you can find my code I have done so far:

http://pastebin.com/K27GUHRY

The syntax is correct, but I think that logic has some sort of an error. Can you please help me make this program more efficient? Once I tried to exit the program, it just continuously runs an infinite loop. Also some of the addition does not display properly.

Please help with this program and provided comments inside the code to see what I did wrong so I can learn from it.

Thanks

Answer
Hello friend,

Your code seems to be working properly OK. The only problem is on this line :

while ((again == 'Y') || (again != 'y'));

this statement is wrong because you are checking that again is equal to caps Y or not equal to smallcaps y. I am guessing it is a typing error.

so, instead of that, simply ensure uniformity in the condition. You want to check that as long as again is either caps Y or small caps y, the programme should continue. The statement below should give your code the right doze of injection :)

while ((again == 'Y') || (again == 'y'));

Goodluck

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


henry

Expertise

I can confidently answer any question both basic and advanced in C++. Areas like templates, algorithms, Gui and design patterns are of interest to me. i will not answer questions about web programming.

Experience

I have a 3- year- work experience in software Engineering.

Education/Credentials
I am a bachelor of Engineering graduate

©2016 About.com. All rights reserved.