003-006-009
Arithmetic Operations with Type Casting
Medium
Problem Description
Arithmetic Operations with Type Casting
In this problem, you will create a program that reads two int values from standard input, performs integer division, uses type casting to obtain an accurate double result, and displays both results to standard output.
Learning Objective: Understand how to apply casting to arithmetic operation results
Overview
Create a program that uses casting to obtain an accurate decimal result from integer division.
Input
a
b
- Line 1: integer
a - Line 2: integer
b(guaranteed non-zero)
Specifications
- Read two integers
aandbfrom standard input - Assign the integer division result to
intResult - Use casting to obtain the accurate division result in
doubleResult - Output both results
Output Format
Int division: [intResult]
Double division: [doubleResult]
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