1. ## two user age

Hey, i have read your book and in if chapter at Practice problems
1. Ask the user for two users’ ages, and indicate who is older; behave differently if both are over 100.
I have a problem with my code below, can you help me please?

Code:
```#include <iostream>

using namespace std;

int main()
{
int first_user_age;
int second_user_age;
cout << "Insert your first age" << '\n';
getline (cin, first_user_age, '\n');
getline (cin, second_user_age, '\n');

bool is_user_user_age_more_than_100 = first_user_age && second_user_age > 100;
if (is_user_user_age_more_than_100)
{
if (first_user_age > second_user_age)
{
cout >> "User age is more than 100 year and the first user is older than the second user" \n;
}
if (first_user_age < second_user_age)
{
cout >> "User age is more than 100 year and the second user is older than the first user" \n;
}
}
bool is_user_user_age_less_than_100 = first_user_age && second_user_age < 100;
if (is_user_user_age_less_than_100)
{
if (first_user_age > second_user_age)
{
cout >> "User age is less than 100 year and the first user is older than the second user" \n;
}
if (first_user_age < second_user_age)
{
cout >> "User age is more than 100 year and the second user is older than the first user" \n;
}
}

return 0;
}```
Why is integer cannot combined with getline ?

I got this message "[Error] C:\Users\Guest\Documents\C-Free\Projects\program\main.cpp:10: error: no matching function for call to `getline(std::istream&, int&, char)'

Likewise the second problem i'm using integer

2. Implement a simple “password” system that takes a password in the form of a number. Make it so that either of two numbers is valid, but use only one if statement to do the check.

if we using string in problem 2 we could get an character besides number

2. Originally Posted by genei
Why is integer cannot combined with getline ?
Because the version of getline that you want to use reads into a std::string, not an int.

One approach is to read the line into a std::string object, initialise a std::stringstream object using this std::string object, and then read into the int variable by using formatted input with the overloaded operator>>

Originally Posted by genei
2. Implement a simple “password” system that takes a password in the form of a number. Make it so that either of two numbers is valid, but use only one if statement to do the check.

if we using string in problem 2 we could get an character besides number
It would probably suffice for you to directly read into the int variables by using formatted input with the overloaded operator>>