C++ Identify first number

this worked.
kind of.

My code is as follows:

    #include "stdafx.h"
    #include <iostream>

    using namespace std;

    int main ()
    {
        int mnum [11];
        int ctr;

        for (ctr=0; ctr<=10; ctr++)
        {
            cout << "Enter your mobile number: ";
            cin >> mnum [ctr];
        }
        cout << "Your mobile number is ";
        if (mnum [3] == 1||2 && mnum [4] == 3||1)
        {
            for (ctr=0; ctr<=10; ctr++)
            {
                cout << mnum [ctr];
            }
        }
        else
        {
            cout << "Sorry. Invalid mobile number prefix." << endl;
            system ("pause");
            return main ();
        }
        return 0;
    }

but i have to enter each number. how to make it entr it in one go and still have the same results?

Browse More Popular Posts

Leave a Comment