Wednesday, June 20, 2012

Program to understand Do While loop

//The body of the loop will be executed at least once before the condition is checked
#include<iostream>
#include<string>
using namespace std;

int main()
{
    string password;
   
    do
    {
        cout << "Enter your password: ";
        cin >> password;
    }
   
    while (password != "foobar");         //notice semicolon
    cout << "welcome, you enterted right password";
}



No comments:

Post a Comment