003-006-009

Arithmetic Operations with Type Casting

Medium

Problem Description

Arithmetic Operations with Type Casting

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.

Specifications

  • Initialize int variables a with 7 and b with 3
  • Assign the integer division result to intResult
  • Use casting to obtain the accurate division result in doubleResult
  • Output both results

Output Format

Int division: 2
Double division: 2.3333333333333335

Ready to Try Running Code?

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

Don't have an account?