Home > Not Working > My Do While Loop Not Working C++

My Do While Loop Not Working C++


int main() { int iPatientNum = 0, iDaysStayed = 0; double dRoomRate = 0, dMedRate = 0, dOtherFees = 0; char cPatientType = '\0'; //Need another while wrapper around everything! Every time I run the program it just skips over it and moves on without even asking for the reply. With it there, JS is trying to re-declare it... If possible though, consider using fgets() instead of scanf() to read in a string. http://elliottwaveresearch.com/not-working/css-top-not-working.html

How to find limit of function. All rights reserved. Is there any way for a planet orbiting a red dwarf in the habitable zone to not be tidally locked? Join them; it only takes a minute: Sign up My do/while loop is not working up vote -2 down vote favorite So I have a do-while loop that's supposed to read http://stackoverflow.com/questions/18893023/my-do-while-loop-is-not-working

My Do While Loop Not Working C++

You have to update the input variable inside the loop. –Math Sep 19 '13 at 11:22 1 sec ill edit to full code –user2764700 Sep 19 '13 at 11:25 I'm trying to ask the user if they want to run the program - yes or no. You can search for fflush, but do NOT use it to flush stdin. (to be lazy you can just put a call to getchar() before fgets to remove the newline, this How to find x and y coordinates based on the given distance?

Can a giant spoon be utilised as a weapon Should I have doubts if the organizers of a workshop ask me to sign a behavior agreement upfront? What is the most someone can lose the popular vote by but still win the electoral college? Why Would the President-elect have a Transition Visit before December 19? Do While Loop Java You need to put that ifclause inside the loop.

Forum Today's Posts C and C++ FAQ Forum Actions Mark Forums Read Quick Links View Forum Leaders What's New? sprintf(tin,"no\0"); You're still writing past the array boundary. 09-07-2005 #5 kermit View Profile View Forum Posts ... How do I make an alien technology feel alien? Continued Last edited on Oct 16, 2009 at 8:17pm UTC Oct 16, 2009 at 8:37pm UTC Beatlesfan94 (2) Here's my revised code, which still doesn't work: 1
#include int main (void)

Welcome."); Tyler Postuma 4,809 Points Tyler Postuma Tyler Postuma 4,809 Points 5 months ago Thank you! Use strcmp or strncmp. Why Would the President-elect have a Transition Visit before December 19? Quzah.

  1. Quick Navigation C Programming Top Site Areas Settings Private Messages Subscriptions Who's Online Search Forums Forums Home Forums General Programming Boards C++ Programming C Programming C# Programming Game Programming Networking/Device Communication
  2. contact us Search: Advanced Forum Search Forums Programming Web Development Computers Tutorials Snippets Dev Blogs Jobs Lounge Login Join!
  3. Our Company About Us Contact Us Community Treehouse Stories Student Perks Treehouse Blog Affiliate Program Careers Topics HTML CSS Design JavaScript Ruby PHP WordPress iOS Android Development Tools Business Tracks Web
  4. If you wish to use scanf() to get a string into an array, use a width specifier something like this: Code: char z[5] scanf("%4s",&z); /* Read in at most 4 chars
  5. You input a 3 digit # like 353 and it shows 3,5, and 3 on separate lines, and then adds them to get 11.

Do While Not Working C++

Did Trump call Belgium a village in Europe? https://teamtreehouse.com/community/why-is-this-dowhile-loop-not-working I have a lot of other stuff on this class, so here is a small excerpt where the do-while is (I have named the variables and all that for everything). My Do While Loop Not Working C++ share|improve this answer answered Sep 19 '13 at 11:12 LuigiEdlCarno 2,03911033 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign Java While Loop Not Working The correct way would be to enter the loop only when the input is out of range.

You forgot to #include main() ought to return something meaningfulL Code: int main(void) { .... http://elliottwaveresearch.com/not-working/bmw-e61-key-fob-not-working.html It's something you should be aware of, as it may affect your comparison. ("no\n" will not match "no") Last edited by spydoor; 09-07-2005 at 03:38 PM. 09-07-2005 #8 rodrigorules View Profile more stack exchange communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed Any suggestions? Why Is My Do...while Loop Not Working

How do unlimited vacation days work? In it, you'll get: The week's top questions and answers Important community announcements Questions that need answers see an example newsletter By subscribing, you agree to the privacy policy and terms BTW, this will be an infinite loop, since the while condition will always be true. navigate here Probably because getchar is often a macro for getc( stdin ).

You need to flush the buffer after your call to scanf. Blueprint a sestina Did the GoF really thoroughly explore "Pattern Space"? So, you need to change you check to be "not equal".

If you type N (capital) or n (lowercase), you get the same result, but in the case, it's working (in a way.) I'm not getting any errors or warnings, since I'm

share|improve this answer edited Nov 5 at 5:22 answered Mar 4 '15 at 6:03 tzhenghao 584 add a comment| Your Answer draft saved draft discarded Sign up or log in Reference Sheets Code Snippets C Snippets C++ Snippets Java Snippets Visual Basic Snippets C# Snippets VB.NET Snippets ASP.NET Snippets PHP Snippets Python Snippets Ruby Snippets ColdFusion Snippets SQL Snippets Assembly Snippets Please sign in or sign up to post. Can leaked nude pictures damage one's academic career?

You know, kinda what comments were made for. Why were pre-election polls and forecast models so wrong about Donald Trump? All standard functions expect char arrays to be NULL terminated. his comment is here Essentially you're doing the opposite of what you want.

more stack exchange communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed Lab colleague uses cracked software. However the following code is not working. { int choice; double hours; cout << "Which Subscription package have you purchased? 1, 2, or 3? " << endl; cin >> choice; switch You don't want to declare secret again inside the loop, just assign it.

share|improve this answer answered Mar 4 '15 at 5:57 Mohit Jain 24.5k83974 I tried that before, you can see the exact code which you wrote under case 2. Does the Rothschild family own most central banks? Thanks in advance c++ while-loop do-while share|improve this question edited Mar 4 '15 at 6:26 Mohit Jain 24.5k83974 asked Mar 4 '15 at 5:52 NewProgrammer 33 add a comment| 2 Answers Dealing With Dragonslayers Did the GoF really thoroughly explore "Pattern Space"?

Below is the corrected code for you to review. do-while: do { // run this code } while (thisStatementIsTrue) NOTE: The condition is tested ONLY at the bottom of the loop, so the body of this loop can execute from Just use an english sentence first to express what you want: As long as c is neither 'O' nor 'I', I want the user to make a new input. => As My boss asks me to stop writing small functions and do everything in the same loop What is the more appropriate adjectival form of Trump?

Oct 16, 2009 at 8:16pm UTC chrisname (7398) Your condition is "while ans isn't Y, N, y or n". Join them; it only takes a minute: Sign up Do While and While Loops not working in C++ code up vote -1 down vote favorite Hi I'm writing a C++ code It will run forever if nothing in the body of loop (or externally, in more advanced cases such as a multi-threaded program) changes the condition. What are some ways that fast, long-distance communications can exist without needing to have electronic radios?

asked 3 years ago viewed 6022 times active 1 year ago Upcoming Events 2016 Community Moderator Election ends in 9 days Get the weekly newsletter!