Welcome To The World Of Hacking


Learn Hacking|Teach Hacking|Learn To Secure|Learn To Code

Friday

C++ TUTORIAL 12: DO...WHILE LOOP

//program to generate a menu to accept and display choice

#include <iostream>
using namespace std;


int main()
{
    char ok;
    int chc;
    do
    { // begining of do...while loop
        ok='n'; // initialize the ok
        cout<<endl<<"Menu";
        cout<<endl<<"1-Create a Folder";
        cout<<endl<<"2.Delete a Folder";
        cout<<endl<<"3.Show a Folder";
        cout<<endl<<"4.Exit"<<endl;
        cout<<endl<<"Your choice:";
        cin>>chc;
        switch(chc)
        {
            case 1: cout<<endl<<"Your choice is 1";
                    break;
            case 2: cout<<endl<<"Your choice is 2";
                    break;
            case 3: cout<<endl<<"Your choice is 3";
                    break;
            case 4: cout<<endl<<"Your choice is 1";
                    break;
            default: cout<<endl<<"Invalid choice";
                    ok = 'n';
        }
    }while(ok == 'n');
    return 0;
}

OUTPUT:

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...