003-002-013

Conditional Expressions with Ternary Operator

Medium

Problem Description

Conditional Expressions with Ternary Operator

In this problem, you will create a program that reads a score and two integers from standard input, uses the ternary operator (?:) to determine pass/fail judgment (60 or above → "Pass", below → "Fail") and find the maximum of the two integers, displaying the results to standard output.

Learning Objective: Understand how to write concise conditional expressions using ternary operator (?:)

Overview

Use ternary operator to select values based on conditions.

Input Format

score
a
b
  • Line 1: Integer score
  • Line 2: Integer a
  • Line 3: Integer b

Specifications

  • Read three integers (score, a, b) from standard input
  • Use ternary operator to determine "Pass" if 60 or above, "Fail" if below
  • Find the maximum of a and b using ternary operator

Output Format

Score <score>: Pass or Fail
Max of <a> and <b>: <maximum>

Sample Input/Output

Input:

75
10
25

Output:

Score 75: Pass
Max of 10 and 25: 25

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