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

Ghulam Ishaq Khn Institute of Engineering

Sciences & Technology

Faculty of Computer Science & Engineering

Open Ended Lab


CS101L: Computing and Artificial Intelligence
Program: BS (Cys)
Total marks: 30
Question 1:
Problem:
A high school has 1000 students and 1000 lockers, one locker for each student. On the first day
of school, the math teacher plays the following game: she asks

• The first student to go and open all the lockers.


• The second student to go and close all the even-numbered lockers.
• The third student to check every third locker. If it is open, the student closes it; if it is
closed, the student opens it.
• The fourth student is asked to check every fourth locker. If it is open, the student closes
it; if it is closed, the student opens it.
• The remaining students continue this game. In general, the nth student checks every nth
locker. If it is open, the student closes it; if it is closed, the student opens it.
After all the students have taken their turn, some of the lockers are open and some are closed.
Write a program that prompts the user to enter the number of lockers in the school. After the
game is over, the program outputs the number of lockers that are open.
Question 2:
You are developing a program for a weather monitoring system that tracks weather data from
multiple weather stations. Design a C++ program that manages temperature, humidity, and wind
speed information for each station. Utilize arrays, functions, and user input to facilitate data
recording and display average weather conditions across all stations.
Process:
• Create arrays to store temperature, humidity, and wind speed data for multiple weather
stations.
• Implement a function to input weather data for a station, allowing the user to add
information for each parameter (temperature, humidity, wind speed).
• Develop a function to display the average temperature, humidity, and wind speed across
all weather stations.
• Use a menu-driven approach to allow users to interact with the weather monitoring
system by choosing options such as inputting data, displaying averages, or exiting the
program.
Question 3:
Problem:
Imagine you are tasked with developing a program for a smart home lighting system. The
program's primary focus is to manage and customize smart light bulbs within a home
environment. Each light bulb is characterized by default attributes such as brightness, color
availability, and color settings. Your objective is to design a program that initializes an array of
these smart light bulbs, allowing users to adjust the brightness of all bulbs or the color of the
lights simultaneously. Simulate the adjustment and customization processes based on user input,
providing a basic yet effective smart home lighting experience.
Note: Make the programs space and time efficient

You might also like