0% found this document useful (0 votes)
3 views

Lab Manual 2

The document outlines the learning outcomes for a course on Control Structures in Artificial Intelligence at the University of Engineering and Technology, Lahore. It includes practice programs and exercises for students to implement various programming tasks using sequential, decision, and repetition structures. The exercises cover topics such as calculating volume, determining grades, and implementing a points system for book purchases.

Uploaded by

pajeg11558
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Lab Manual 2

The document outlines the learning outcomes for a course on Control Structures in Artificial Intelligence at the University of Engineering and Technology, Lahore. It includes practice programs and exercises for students to implement various programming tasks using sequential, decision, and repetition structures. The exercises cover topics such as calculating volume, determining grades, and implementing a points system for book purchases.

Uploaded by

pajeg11558
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Artificial Intelligence

Department of Computer Science


University of Engineering and Technology, Lahore

Class Learning Outcomes:


Students shall be able to learn

• Control Structures
CLO2
o Sequential Structure
o Decision/Selection Structure
▪ if statement
▪ if/else statement
▪ if/elif/else statement
o Repetition Structure
▪ while structure
▪ for structure

Practice Programs
Write the following program in your jupyter notebook and state the output in the space provided.

Program to add two numbers 0.5


Program to find velocity of a moving object 0.5

Program to find Subject Status 1

What’s the output with the following input?

Grade = 60 Grade = 70 Grade = 30


Attendance = 40 Attendance = 75 Attendance = 95
Program to find mess menu 1

What’s the output with the following input?

Day = Friday Day = funday Day = monday

Program to check positive or negative number 1


What’s the output with the following input?

Number = 10000 Number = 0 Number = -90

Program to write numbers in a range with mentioned steps 1

What’s the output with the following input?

Start = 0 Start = 100 Start = -100


Stop = 100 Stop = 0 Stop = -200
Step = 10 Step = -10 Step = -10
Program to write tables 1

What’s the output with the following input?

Number = 5 Number = 12 Number = 73

Exercise 2 x 10
1. Write a program to find the volume of cylinder (the cylinder's volume is π r² h)

2. Write a program that separately prints even numbers and odd numbers from a range
specified by the user

3. Write a program to calculate sales tax on an item sold. Consider the following
information:
Price of one packet of jellies = 10 rs
Price of one packet of juice = 50 rs
Price of one bag of chips = 40 rs
Price of one cup of ice-cream = 60 rs
Price of one bar of chocolate = 35 rs
Sales Tax = 5% of the item price

4. Write a program to calculate grade of each student. Consider the following information;
a. Grade A for students who obtain marks greater than or equal to 85%
b. Grade B when marks are greater than or equal to 75%
c. Grade C when marks are greater than or equal to 65%
d. Grade D when marks are greater than or equal to 55%
e. Grade E when marks are greater than or equal to 45%
f. Grade F when marks are below than 45%
g. Invalid marks if marks are greater than 100 or less than 0
h. Also adjust A+, B+, C+, D+, E+ grades

5. Serendipity Booksellers has a book club that awards points to its customers
based on the number of books purchased each month.
The points are awarded as follows:
• If a customer purchases 0 books, he or she earns 0 points.
• If a customer purchases 1 book, he or she earns 5 points.
• If a customer purchases 2 books, he or she earns 15 points.
• If a customer purchases 3 books, he or she earns 30 points.
• If a customer purchases 4 or more books, he or she earns 60 points.

Write a program that asks the user to enter the number of books that he or she has purchased this
month and then displays the number of points awarded.

6. Write a Menu driven program that outputs the following information about the shape:
a. For a rectangle, it outputs the area and perimeter
b. For a circle, it outputs the area and circumference
c. For a cylinder, it outputs the volume and surface area

7. Write a program to add numbers as much as the user wants. Hint: use while loop

8. This program displays the numbers 1 through 10 and their squares. Hint use for loop

9. Write a C++ Program that read an alphabet (e.g. a,b,c,d,…..z) and display whether the
input alphabet is a vowel (i.e. a, e, i, o, u) or consonant.

10. Consider the following program and output


What should be the values of start, stop and step variables to draw the following pattern?

You might also like