Can't input integers after reading a character

#include <iostream>
using namespace std;

int Variable() {
    char Letter= ' ';
    cout << "Your Name: ";
    cin >> Letter;
    cout << "Your first Letter is : " << Letter;

return 0;
}

int userInput(int number)
{
    int input = 0;
    cout << "Give me your " << number << ". number: ";
    cin >> input;
    cout << "\n";
    return input;
}


int main() {

    Variable();

    int input1 = 0;
    int input2 = 0;


    input1 = userInput(1);
    input2 = userInput(2);

    cout << "Result: " << (input1 * input2) << "\n\n";
    

    return 0;
}

Output:

Your Name: Kevin
Your first Letter is : K

Give me your 1:
Give me your 2:
Result: 0

I write in the console a name and after that I get the first Letter, but after that I cant enter the two numbers because the programends. I dont understand why the program skips the userInput function.



from Recent Questions - Stack Overflow https://ift.tt/3CiaIcb
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation