Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

CS100 Computational Problem Solving Fall 2021-2022 Sarvech Qadir

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

CS100 Computational Problem Solving

Fall 2021-2022
Sarvech Qadir

Section 2 Friday 17th Sept

Lab# 02: Exercise

Lab Guidelines

1. You are allowed to perform/submit the lab only during the lab timings
2. Make sure you do not leave the lab without submitting your work on LMS
3. Copying/sharing code is strictly prohibited. Using any unfair means will lead to immediate
disqualification
4. Put all cpp files into a folder YourRollNo_Lab2_TAname and submit it on LMS
(Assignments>Lab2)
5. Lab ends at 8:50 pm and the submission tab closes at the same time

Task1 Total
25

Task2 Total
25

Task3 Total
30

Total Marks: 100( 80 + 20 for Viva)


Task 1 - Simple output/print [25 marks]

Write code to print the following information about yourself in 3 lines:

Hello, I am Ahmed.
My roll number is 22100110.
I am from Lahore.

__________________________________________________________________

Task 2 - Int & double variables [25 marks]

Write a program to show expected rainfall and actual rainfall in a week. It is


expected that it will rain 4 days in the week with average rainfall of 250.6mm. In
reality, it rained 2 days in the week with average rainfall of 90.8mm You will display
the expected number of days it will rain along with expected average rainfall of the
week. Using the same variables, you will output the actual number of days it rained
along with actual rainfall in the week. You will display these values for two
categories:

1. Expected rainfall
2. Actual rainfall.

You need to store these values in int/double variables and display these
variables. You can only use 2 variables in the whole program. For example, there
will be a single variable for both expected average rainfall and actual average
rainfall, and so on. You will use variable assignments to change the values of these
variables to display your actual values once you have displayed the goal values.

Whether a variable should be an int or a double is for you to figure out, depending
upon what you have learnt in class.

Please follow the sample output format below:

Expected rainfall:
Number of days it will rain: 4
Average rainfall(mm): 250.6
Actual rainfall:
Number of days it rained: 2
Average rainfall(mm): 90.8
________________________________________________________________

Task 3 - Escape Sequences [30 marks]

Write a program that prints the character ‘A’, ‘R’, ‘M’ as shown below. You are
supposed to use escape sequences (table at the end of the document) wherever
possible. Full credit will only be provided to students who don’t violate the following
rules:

1. You can’t use endl.


2. You can’t use consecutive white spaces.

25 marks are for printing the characters correctly as shown below, and 5 marks are
for not violating the rules above.
___________________________________________________________________

Escape Sequence Function

\n New line

\\ backslash

\’ Single quote

\’’ Double quote

\b Backspace

\t Tab (4 spaces)

You might also like