When only Some specific user name will be greeted in a C++ Program.

Modification of previous program.

Program:

#include<iostream>
#include<string> //here string file is used to use string reserved keyword
using namespace std;

int main()
{
    string Name, response;

    cout<<"Please give Your name : ";

    getline(cin, Name); //getline is used to store character entered after space button is clicked

    if((Name=="Alice")||(Name=="Bob"))  //Here || is logical OR operator.

    {
        cout<<"Namaste, "<<Name;
    }

    else
    {
        cout<<"You are out of the program";
    }

    return 0;
}

Note : If you want to see the previous program then click here PROGRAM

Comments

Popular posts from this blog

A program to Add numbers divisible by 3 or 5 in C++

C++ Programming Language Easy Course