#include <iostream>
int main()
{
int age;
std::cout << "age? ";
std::cin >> age;
if( 5 <= age && age <= 10 ) age -= 5 ; // subtract 5 from it
elseif( 0 <= age && age <= 4 ) age *= 2 ; // multiply it by 2
// else leave it unchanged as the the original value
std::cout << age << '\n' ; // in any case, print it out
}
if (5 <= age && age <= 10)
{
age = age - 5;
cout << age;
}
if (0 <= age && age <= 4)
{
age = age * 2;
cout << age;
There are integers where both these conditions hold true. Lets use 6 as our example.
> age = 6;
> First condition
> 5 < age < 10
> age - 5
> cout << age // which is 1
> Second conditon
> 0 < age < 4
> age * 2
> cout << age // which is 2
>>> displays: 12
You are close, you need to double check your if statement