Professional Documents
Culture Documents
LAB NO : 2
TASK # 1
Objective:
Write a C++ Program which reads the input for the following information and
then prints it in the following format. The data type for “dues” should be saved
as Boolean (bool). If there are any remaining dues, enter true and it will print 1
and vice versa. Save the patient’s ID with const keyword, try to change the
value of that variable after successfully printing the following information
once. Patient’s ID: 0123
Full name: ABC
Age: 70
Contact no: 000000000
Address: XYZ
Department name: (For Example: Accident & Emergency, Neurology, ENT etc.)
Assigned Doctor: XYZ
Date: ------------
Dues: 0
Source code:
Output:
TASK # 2(1)
Objective:
Implement the above two Examples of Implicit Casting with user input.
Source code:
Output:
TASK # 2(Example 2)
Source code:
Output:
TASK # 3
Objective:
Write a C++ program that reads a number in inches, converts it to meters.
Test Data
Expected Output:
Source code:
Output:
TASK # 4(a)
Objective:
Write a C++ program which reads number of eggs in each basket and total
number of baskets from user, then calculates and prints result like following:
Source code:
Output:
TASK # 4(b)
Objective:
b) Now alter the scenario and ask the user “how many eggs would you like to take
from each basket?” Then calculates the number of remaining eggs accordingly.
Source code:
Output:
TASK # 5(a)
Objective:
Write a C++ program which initializes three variables with data type int, signed
int and unsigned int. Now read a whole number with negative sign in int type
variable, assign the same value to other two variables, then print all the three
integers and observe the output. In Second Case, read a positive number from
the user and observe the output
Source code:
Output:
Output:
TASK # 6
Objective:
Implement the Explicit type casting for every type as shown in above
hierarchy.
Source code:
Output: