003-002-007

Comparison Operators: Age Comparison

Easy

Problem Description

Comparison Operators: Age Comparison

In this problem, you will create a program that reads two ages, determines their relationship using comparison operators (>, <, ==) combined with if-else statements, and displays the result to standard output.

Learning Objective: Learn to combine comparison operators (>, <, ==) with if-else statements to evaluate multiple conditions

Compare ages of two people and determine who is older. Use comparison operators and if-else statements to check magnitude relationships.

Input

Line 1: Person A age (integer)
Line 2: Person B age (integer)

Output

If A is older:

Person A: [age1] years old
Person B: [age2] years old
Person A is older

If B is older:

Person A: [age1] years old
Person B: [age2] years old
Person B is older

If same age:

Person A: [age1] years old
Person B: [age2] years old
Same age

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up