|
-
April 20th, 1999, 03:47 PM
#5
Re: Please Help Me with this code
The reason you keep going to the default in the switch is the while loop
while (( Pnumber = getchar() ) !=EOF )
Pnumber is reset (Pnumber = getchar()) after the initial entry after the prompt. (cin >> Pnumber)
Why do you redeclare each of the variables within each case of the switch statement. They will go out of scope when you exit the swtich statement and the wrong values will be output at the end of the program.
Note that you will only be prompted once for what to enter. You may want to move the prompting to within the loop.
Hope this helps.
Chuck Grady
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|