I am very new to C++. I am learning the language by myself. I tried to make a program where the user inputs how old they are (in terms of years) and the program will output how old the user is, in terms of months. The problem I am encountering is that the console will ask me for my age which I put in and click enter. Nothing happens other than the text cursor moving to the line below it. However, once the text cursor is on the second line, and I retype in the years, it outputs the number of months. My question is why does the program not output the number of months, when I type in the number of years in the first line?

Here is an image of the problem:

Here is the code :

#include <iostream>

using namespace std;

int main()
    int years;

    cout << "How old are you?";
    cin >> years;
    cout << years * 12;
Attachments entertwice.png 20.32 KB

just remove the cin.ignore() it is saying "forget the first thing that the user enters" you don't want that.

This question has already been answered. Start a new discussion instead.