Thread: Loops

  1. #16
    Registered User
    Join Date
    Sep 2011
    Oh. Now that one makes sense. Thanks. Um. I guess I will show you what i thought was suppose to be for the password one, i know it is wrong but i did not know what else to do....

    #include <cstdlib>
    #include <iostream>
    #include <string>
    using namespace std;
    int main(int argc, char *argv[])
            string var;
            cout<<"Please enter the password."<<endl;
            while (var=="sad")    
                   cout<<"You guessed that the password was "<<var<<" which was correct. Good job."<<endl;
        return EXIT_SUCCESS;

  2. #17
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    No, while is not equivalent to if.
    In this case you need to repeatedly execute the portion where the user enters the password and it turns out to be wrong.
    Consider a freebie
    using namespace std;
    int main()
        string pass("your_pass"), temp;
            else cout<<"Try Again"<<endl;
        //...other parts
        return 0;
    Last edited by manasij7479; 09-25-2011 at 02:35 PM.

  3. #18
    Registered User
    Join Date
    Sep 2011
    Okay.... I will go figure out how to do that.

  4. #19
    Join Date
    Oct 2007
    Inside my computer
    Quote Originally Posted by CommonTater View Post
    Sometimes the best lessons are the least comfortable ones.
    Programming is not an area of expertise where one can "loaf along" and be good at it, it requires a certain analytical mindset... and you don't get that from Google.

    Offending post removed.
    I agree with you, but instead of being offensive, you can calmly state the facts and point to helpful resources.

    Do you have a basic understanding of what various loops there are in the language? If not, check out the lessons on this site.
    Afterwards, I think you should introduce yourself to flow charts. They are extremely good tools for newbies who have yet to grasp how to "naturally" translate logic into a programming language.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 06-01-2011, 04:19 PM
  2. loops, menu loops
    By gloworm in forum C Programming
    Replies: 17
    Last Post: 04-12-2010, 07:59 PM
  3. Help with C, loops
    By Bobbismal in forum C Programming
    Replies: 3
    Last Post: 09-12-2009, 06:07 AM
  4. help with loops
    By lpaolini436 in forum C Programming
    Replies: 8
    Last Post: 11-10-2006, 01:51 PM
  5. For Loops!!!
    By Nailogamer in forum C++ Programming
    Replies: 5
    Last Post: 08-14-2003, 06:46 PM