QUESTION DESCRIPTION
TEST CASE 1
INPUT
In Argentina the COUPLE GAMESHOW named You and Me is going to happen.
In order to complete the application process for the game show the participants need to find their average age.
Can you help them them to find their average age?
NOTE:
The Programming Language need to be used is : C++
Refer sample input and output in the test cases.
TEST CASE 1
INPUT
28
24
OUTPUTI am 28
You are 24
We are around 26
#include <iostream>
using namespace std;
int main() {
int a,b,avg;
cin>>a>>b;
avg=(a+b)/2;
cout<<"I am "<<a<<endl<<"You are "<<b<<endl<<"We are around "<<avg;
return 0;
}
Helping Participants Calculate Their Average Age for the "You and Me" Game Show
In Argentina, the popular couple game show named "You and Me" is about to take place. As part of the application process, participants need to calculate their average age. Let’s create a simple C++ program to help them do just that.
Problem Description
You need to write a C++ program that:
- Takes the ages of two participants as input.
- Outputs the individual ages and their average age.
For example:
- Input:
- Age of person 1:
28
- Age of person 2:
24
I am 28
You are 24
We are around 26
Breaking Down the Solution
To solve this, we'll:
- Read the ages of the two participants.
- Calculate the average of the two ages.
- Display the ages of each participant and the average age in the specified format.
The Code Explanation
Here’s how the code works:
#include <iostream>
using namespace std;
int main() {
int age1, age2, avg;
// Read the ages of the two participants
cin >> age1 >> age2;
// Calculate the average age
avg = (age1 + age2) / 2;
// Output the results in the required format
cout << "I am " << age1 << endl;
cout << "You are " << age2 << endl;
cout << "We are around " << avg << endl;
return 0;
}
ow the Code Works
- Input Handling: The program reads two integers,
age1
and age2
, which represent the ages of the two participants. - Average Calculation: The average age is calculated using the formula
(age1 + age2) / 2
. - Output: The program then prints the following:
- "I am <age1>"
- "You are <age2>"
- "We are around <average age>"
Sample Test Cases
Test Case 1:
- Input:
28
24
- Output:
I am 28
You are 24
We are around 26
Test Case 2:
- Input:
30
32
- Output:
I am 30
You are 32
We are around 31