0% found this document useful (0 votes)
105 views4 pages

CS 100 Lab 6 Tasks

1) The document outlines the tasks and guidelines for Lab #06 in the CS100 Computational Problem Solving course for Fall 2021-2022. 2) It describes 3 tasks - finding the sum of a series using loops, identifying shapes based on user input, and looking up a student's grade for a course. 3) Guidelines are provided for submitting the lab work, including putting files in a folder and submitting by the deadline.

Uploaded by

Hassan Waqar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views4 pages

CS 100 Lab 6 Tasks

1) The document outlines the tasks and guidelines for Lab #06 in the CS100 Computational Problem Solving course for Fall 2021-2022. 2) It describes 3 tasks - finding the sum of a series using loops, identifying shapes based on user input, and looking up a student's grade for a course. 3) Guidelines are provided for submitting the lab work, including putting files in a folder and submitting by the deadline.

Uploaded by

Hassan Waqar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CS100 Computational Problem Solving

Fall 2021-2022
Saood Ahmad

Section 2 Friday 15 Oct

Lab# 06: 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_Lab6_TAname and submit it on LMS
(Assignments>Lab4)
5. Lab ends at 8:50 pm and the submission tab closes at the same time

Task1 Total
20

Task2 Total
30

Task3 Total
30

Total Marks: 100 (80 + 20 for Viva)


Task 1 - Sum of nth terms in a series [20 marks]

Write a program in C++ to find the sum of the series 1 + 1/2^2 + 1/3^3 + ……. + 1/n^n.
Where the value of n is entered by the user.
You are only allowed to use While or Do-While loops

Sample Output:

Input the value for nth term: 5

1/1^1 = 1
1/2^2 = 0.25
1/3^3 = 0.037037
1/4^4 = 0.00390625
1/5^5 = 0.00032
The sum of the above series is: 1.29126

Task 2 - Shape identifier [30 marks]

Consider four kinds of shapes:


1. Rectangle: Only opposite sides are equal, all angles 90 degrees
2. Square: All sides are equal, all angles 90 degrees
3. Rhombus: All sides are equal, no angle is 90 degrees
4. Rhomboid: Two pairs of parallel sides, two pairs of sides equal in length, no angle is
90 degrees

Write a program that asks the user relevant questions in order to guess one of the
four-sided shapes given. Phrase all questions such that the user should only answer in
terms of “YES” or “NO.” The program should not terminate after running once, but
instead should ask the user if they want to check another shape. (Hint: a Do - while
loop can be used here)

Sample output:

Q: Are all sides equal?


A: YES

Q: Are all angles 90 degrees?


A: NO

It is a rhombus!

Q: Would you like to try again?


A: YES

Q: Are all sides equal?


A: YES

Q: Are all angles 90 degrees?


A: YES

It is a square!

Q: Would you like to try again?


A: NO

“Good bye”

Task 3 - Grade Finder [30 marks]

The following table contains the courses and grades obtained in those courses by 3
students. Write a program that takes in the name of a student, then asks you to input
one of the 3 courses (CS100, CS200, CS225), and then outputs the grade of the
student in that course.
Name Course Obtained Grade

Mukeet CS100 A

Mukeet CS200 A-

Mukeet CS225 B+

Esha CS100 A*

Esha CS200 B

Esha CS225 B+

Emaan CS100 B-

Emaan CS200 A*

Emaan CS225 A*

Sample Output:

Enter Student Name:


Mukeet

Enter Course Code:


CS225

Mukeet's grade in CS225 is: "B+"

You might also like