As I fixed it I encountered another problem, when I run the program and it asks me for metres I enter it and then it goes straight to the last else sentence where it displays the correct entered value of P but does not even give me a chance to enter U
19 Replies - 250 Views - Last Post: 31 January 2013 - 01:29 PM
#16
Re: Having trouble fixing my errors in the code
Posted 31 January 2013 - 11:03 AM
Courtesy of writing a single sentence and then copypasting it
As I fixed it I encountered another problem, when I run the program and it asks me for metres I enter it and then it goes straight to the last else sentence where it displays the correct entered value of P but does not even give me a chance to enter U
As I fixed it I encountered another problem, when I run the program and it asks me for metres I enter it and then it goes straight to the last else sentence where it displays the correct entered value of P but does not even give me a chance to enter U
#17
Re: Having trouble fixing my errors in the code
Posted 31 January 2013 - 11:19 AM
I'm going to bow out of the conversation now.
It seems you've stopped debugging your own homework because we're doing it for you.
Nothing you've done or are doing is hard. It just requires you to pay attention and make a little more effort.
Step through your program in the debugger line by line and look at the values of the variables and *think* as to why each if passes or fails. Logic and reasoning skills will take you a long way.
From my FAQ list:
Q: I do x and y happens which I didn't expect but I don't know how to figure out why. How do I debug and find my problem?
A:
It seems you've stopped debugging your own homework because we're doing it for you.
Nothing you've done or are doing is hard. It just requires you to pay attention and make a little more effort.
Step through your program in the debugger line by line and look at the values of the variables and *think* as to why each if passes or fails. Logic and reasoning skills will take you a long way.
From my FAQ list:
Q: I do x and y happens which I didn't expect but I don't know how to figure out why. How do I debug and find my problem?
A:
- Debugging video 1: Breakpoints and Local variables
- Debugging video 2: Advanced breakpoints
- Debugging tutorial
- Debugging tips
- Debugging in detail
- Great debugging tips
- It still doesn't work, article
- Debugging tools survival guide
- Video: Tips & Tricks to use Visual Studio to the fullest
This post has been edited by tlhIn`toq: 31 January 2013 - 11:22 AM
#18
Re: Having trouble fixing my errors in the code
Posted 31 January 2013 - 11:21 AM
tlhIn`toq, on 31 January 2013 - 11:19 AM, said:
I'm going to bow out of the conversation now.
It seems you've stopped debugging your own homework because we're doing it for you.
Nothing you've done or are doing is hard. It just requires you to pay attention and make a little more effort.
Step through your program in the debugger line by line and look at the values of the variables and *thing* as to why each if passes or fails.
From my FAQ list:
Q: I do x and y happens which I didn't expect but I don't know how to figure out why. How do I debug and find my problem?
A:
It seems you've stopped debugging your own homework because we're doing it for you.
Nothing you've done or are doing is hard. It just requires you to pay attention and make a little more effort.
Step through your program in the debugger line by line and look at the values of the variables and *thing* as to why each if passes or fails.
From my FAQ list:
Q: I do x and y happens which I didn't expect but I don't know how to figure out why. How do I debug and find my problem?
A:
I was actually watching these videos as I waited for a reply from the community, I have used do&while earlier for programs with multiple questions. Is that what I should now?
In addition , I use devcpp as it is required by the lecturers of my eCourse.
This post has been edited by needhelpest: 31 January 2013 - 11:24 AM
#19
Re: Having trouble fixing my errors in the code
Posted 31 January 2013 - 12:01 PM
Tried using do-while method from my previous experience, the problem remains the same.
#20
Re: Having trouble fixing my errors in the code
Posted 31 January 2013 - 01:29 PM
This is a common problem for beginners.
cin >> P; leaves a newline in the input stream.
getline(cin, U); reads the newline as an empty string.
There are various ways of dealing with this such as using the ignore function.
Here though you can just use another cin >>, I think.
26 cin >> P; 29 getline(cin, U);
cin >> P; leaves a newline in the input stream.
getline(cin, U); reads the newline as an empty string.
There are various ways of dealing with this such as using the ignore function.
Here though you can just use another cin >>, I think.
26 cin >> P;
29 cin >> U;
|
|

New Topic/Question
Reply




MultiQuote




|