003-006-008

Combining Multiple Type Conversions

Medium

Problem Description

Combining Multiple Type Conversions

In this problem, you will create a program that reads a double variable from standard input, performs successive cast conversions to int and char types, and displays each result to standard output.

Learning Objective: Understand how to combine casting conversions between different types

Overview

Create a program that reads a double value from standard input, performs conversions between multiple data types, and outputs each result.

Specifications

  • Read a double value from standard input and assign it to original
  • Cast to int type and assign to intValue
  • Cast intValue to char type and assign to charValue
  • Output all three values in order

Input Format

<double value>

Output Format

Original: <original>
Int: <intValue>
Char: <charValue>

Example

Input:

123.456

Output:

Original: 123.456
Int: 123
Char: {

Note: ASCII code 123 is '{'

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