4. A person is going on a motorway and at one point he can see roads going in three different directions. Based on the destination, he will move either toward left, right or straight. Write a C++ program that guides the traveler based on the following directions:
• If destination is Lahore, then turn left.
• If destination in Islamabad or Murree, then turn right. • Otherwise move straight.
Here is program:
int main()
{
int destination;
cout << "Enter destination: " << endl;
cout << "1)Lahore" << endl;
cout << "2)Islamabad" << endl;
cout << "3)Murree" << endl;
cin >> destination;
if (destination == 1)
{
cout << "Turn left" << endl;
}
else if (destination == 2 || destination == 3)
{
cout << "Turn right" << endl;
}
else
{
cout << "Move straight" << endl;
}
}
Comments
Leave a comment