Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

DO Until loops for iostream

does anyone know the syntax for the do until loop(derivitive of do while)

and if their is an addtional header file i need to declare.

Comments

  • : does anyone know the syntax for the do until loop(derivitive of do while)
    :
    : and if their is an addtional header file i need to declare.

    There is no 'do until' loop in C or C++. You have three looping constructs: 'for', 'while', 'do while'. It's actually much better this way, because the meaning of the loop test is the always the same: "loop while the test evaluates to true". The only difference is whether the test is at the top or the bottom of the loop. The 'do until' style of loop changes the meaning of the loop test: "loop while the test evaluates to false".

    Cheers,
    Eric

  • : : does anyone know the syntax for the do until loop(derivitive of do while)
    : :
    : : and if their is an addtional header file i need to declare.
    :
    : There is no 'do until' loop in C or C++. You have three looping constructs: 'for', 'while', 'do while'. It's actually much better this way, because the meaning of the loop test is the always the same: "loop while the test evaluates to true". The only difference is whether the test is at the top or the bottom of the loop. The 'do until' style of loop changes the meaning of the loop test: "loop while the test evaluates to false".
    :
    : Cheers,
    : Eric
    :

    Maybe it's better with a do until loop,
    but when you use the while loop with a NOT into it, it's the same kind a thing.

    // example;
    // the way you mean
    while (VALUE) {

    }

    // my way
    while (!VALUE) {

    }

    // it's the same as do until


  • : // my way
    : while (!VALUE) {
    :
    : }
    :
    : // it's the same as do until

    That's still not the same as 'do until', because the test is at the top. The equivelant of 'do until' would be this:

    [code]do {
    // some stuff
    } while (!VALUE);[/code]Cheers,
    Eric



  • yeah i know, i normaly use reg do while or for loops, but when my instructor said useage of a do until loop, i didnt know what the hell he was talking about, im sure he means just a rendition of a do while

    i.e.

    char word[20];
    float k,y;
    y=1;
    cout<<"The do while loop does what it says, it does while, watch
    ";
    cout<<"we will print out a word
    ";
    cout<<"enter word: ";
    cin>>word;
    cout<<"
    enter constant(the while), it will print out the word this many times: ";
    cin>>k;
    cout<<endl<<endl;
    do
    {
    y=y+1;
    cout<<word<<"
    ";
    }
    while(y!=k+1);
    cout<<endl<<endl;
    main();
    }

Sign In or Register to comment.