20.3k views
4 votes
Write two cin statements to get input values into birthMonth and birthYear. Then write a statement to output the month, a dash, and the year. End with newline. The program will be tested with inputs 1 2000 and then with inputs 5 1950. Ex: If the input is 1 2000, the output is: 1-2000 Note: The input values come from user input, so be sure to use cin statements, as in cin >> birthMonth, to get those input values (and don't assign values directly, as in birthMonth = 1). 1 2 3 4 5 6 7 8 9 10 11 #include using namespace std; int main() { int birthMonth; int birthYear; /* Your solution goes here */ return 0; }

1 Answer

3 votes

Answer:

#include <iostream>

using namespace std;

int main()

{

int birthMonth, birthYear;

cout << "Enter your Birth Month and Year" << endl;

cin>>birthMonth;

cin>>birthYear;

cout<<birthMonth;

cout<<"-";

cout<<birthYear<<endl;

return 0;

}

Step-by-step explanation:

Using C++ Programming Language, Firstly we declare to variables to hold the values for the birthMonth and birthYear. We then used a cout statement to prompt the user to input values for month and year, then three cout statements are used to display the output according to the question's specification.

User Davidmpaz
by
4.8k points