how can i Write a C++ program to display cities of USA using switch case
newyork,virginia,texas,hollywood,chicago & newmexico

Member Avatar for Search_not

If you display a list and allow the user to choose one city using a integer input. I'm not sure if you can use a string in a Switch-statement... C++11 might allow you to, but nothing older.

The list would look something like this:

#include <iostream>

using namespace std;

int main(void){
    int Input;
    char List[] = "States: "
                  "\n\t1 - Virginia "
                  "\n\t2 - Texas ";

    cout << List << endl;
    cin >> Input;

    switch(Input){
        case 1:  //insert your own code here
            break;
        case 2:  //and here
            break;
        default:   //and here
            break;
    }

    return 0;
}

how can i Write a C++ program to manipulate string function using 12 condition

#include <iostream>

using namespace std;

int main(void){
    int Input;
    char List[] = "States: "
                  "\n\t1 - Virginia "
                  "\n\t2 - Texas ";

    cout << List << endl;
    cin >> Input;

    switch(Input){
        case 1:  //insert your own code here
            cout << "Virginia" << endl;
            break;
        case 2:  //and here
            cout << "Texas" << endl;
            break;
        default:   //and here
            break;
    }

    return 0;
}

if array value is too small.
explain code like this. too simple.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.