Professional Documents
Culture Documents
Assignment 01
CLO 2
Total Marks: 10 marks
Instructions:
All tasks must contain algorithm, flow charts, C++ coding, comments and all varieties of outputs.
Assignments to be submitted on both hardcopy and softcopy. Softcopy is to be uploaded on LMS,
while hardcopy must be done handwritten on A4 pages, and submit it in a proper file.
Assignment after due date will not be accepted.
Assignment will not be returned back.
1. Structure of a program
A. Write a program that displays your favourite poem/verse/stanza. Use an appropriate escape
sequence for the line breaks.
B. Write a program using different datatypes that convert Pakistani Rupees into US dollars and UAE
Darham
■ 1 US $ = 152.3 PKR
■ 1 AED = 41.46 PKR
C. Write a program takes radius, length, base and height as inputs from the user and displays the Area
of Circle, square and triangle
D. Write a program that asks user to input the PKR amount and then convert and display it into US
dollars and UAE Darham
■ 1 US $ = 152.3 PKR
■ 1 AED = 41.46 PKR
4. Decisions
A. Write a temperature-conversion program, that gives the user the option of converting Fahrenheit
to Celsius or Celsius to Fahrenheit. Then carry out the conversion. Use floating-point numbers.
Option should be taken as Character input.
B. Discount of 20% is offered if quantity of item purchased is more than 50. Quantity and price of
item are taken as input from user. Write a program to calculate the cost of items. Use if-else for
“discounted” or “no discount” messages.
C. An automatic waiter is installed in a restaurant that serves the complementary coffee to all the
tables along its path. The automatic waiter has three sensors (S1, S2, S3) attached at its bottom to
sense the path and takes decision whether to turn left or right or move straight or stop. Program
the waiter that makes it able to take decisions as per the paths defined, and successfully reaches to
its destination.
D. Input the percentage of student and display his/her grade Using chain if-else structure.
E. (a) Write a program that takes alphabet as an input from user and display the message, if it is
Vowel or Consonant.
(b) Also indicate if the letter entered is Capital or Small?
F. Calculate discriminant with conditions of real or equal or imaginary roots.
(D == 0, equal roots), (D>0,real roots) and (D<0, imaginary roots).
G. Create the equivalent of a four-function calculator. The program should ask the user to enter a
number, an operator, and another number. (Use floating point.) It should then carry out the
specified arithmetical operation: adding, subtracting, multiplying, or dividing the two numbers.
Use a switch statement to select the operation. Finally, display the result.
H. Ask the student to enter lecture number (1-4) and show the list of Exercises using switch statement.
If the user enters any lecture other than 1-4, display an appropriate message.
Write a program that generates the interactive output console to the counter boy; Looking at which he can
easily know the quantity of notes needed to return to the customer. For Example two notes of 1000, three
notes of 100 and so on.
Use modulo operator to keep the remainders. User list of variables. Use escape sequences to make the
output interactive. Use setw manipulator to set width.
Good Lcuk