Activity: Typecasting (iPad)

The Assignment

Working with your partner, write a program which outputs the result of dividing one number (x) by another (z), using both floating-point division and integer division. For example, if the input is 9 2.5, the output should be

9/2.5 = 3.6
9/2.5 = 4

Begin by creating a new C++ file called Typecasting.cpp in the iPad C++ compiler. Next, copy and paste this starter code into the file:

#include <iostream>
#include <cmath>

using namespace std;

int main() 
{
   int x = 0;
   double z = 0;
   
   cin >> x >> z;
   
   cout << x << "/" << z << " = ";
   // output the floating-point result with a newline character at the end...


   cout << x << "/" << z << " = ";
   // output the integer result with a newline character at the end...   


   return 0;
}

Modify the code to complete the assignment. When you have completed the assignment, demonstrate it for the instructor.