Question: C++ 1. Write a program to read in a character, an integer, and a float, and print out the values, then cast to other types;
C++
1. Write a program to read in a character, an integer, and a float, and print out the values, then cast to other types; so that the interaction with the user is something like the following:
Input a single character, followed by : h Input an integer, followed by : 4872 Input a float, followed by : 182.937 The character h when cast to an int gives value ????? The character h when cast to a float gives value ????? The integer 4872 when cast to a char gives value ? The integer 4872 when cast to a float gives value ????? The float 182.937 when cast to a char gives value ? The float 182.937 when cast to an int gives value ?????
2. Write a program with a recursive function, which calls itself to a certain call depth, e.g 10, and then throws an exception. The function shall as argument have the call depth when the exception is to be thrown. Let main() catch the exception and print at which call depth the exception was thrown. The call depth when the exception is to be thrown shall be given on the command line when the program is started. A run can look as follows, if the name of the program is throwup: %unix throwup 10 exception thrown at call depth 10.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
