Practice Question EE-B
Question No. 01
Suppose you are required to build a console-based application that simulates a Smart Parking
Lot Counter System for a small commercial area with a fixed capacity of 10 parking slots. The
purpose of this system is to assist parking attendants in tracking the entry and exit of vehicles in
real-time.
The system should store and manage parking slot data using arrays, where each element represents
a parking slot (1 for occupied, 0 for available). You are required to use pointers to manipulate the
array during parking and un-parking operations. Implement user-defined functions for the
following tasks:
1. Allowing a car to enter (assign a free slot).
2. Allowing a car to exit (free the occupied slot).
3. Displaying the current status of all parking slots.
4. Displaying the number of currently available slots.
5. Searching for a car by a unique token/ID (optional simulated feature).
Each parked car should be assigned a unique parking token or ID, which may be generated using
a built-in function such as rand() if applicable.
The application must be menu-driven, utilizing a switch statement to handle the following
options:
1. Park a car
2. Remove a car
3. View parking lot status
4. Display number of available slots
5. Search for car by token/ID
6. Exit
Additionally, the logic should involve at least one instance, each of for, while, and do-while loops
in appropriate parts of the program. The system should validate inputs (e.g., no over-parking, no
removal from an empty or unassigned slot), ensure a modular program structure using functions,
and provide clear and formatted console output for ease of use.
Engr. Eman Fatima
Question No. 01
Suppose you are required to build a console-based application that simulates a Smart Parking
Lot Counter System for a small commercial area with a fixed capacity of 10 parking slots. The
purpose of this system is to assist parking attendants in tracking the entry and exit of vehicles in
real-time.
The system should store and manage parking slot data using arrays, where each element represents
a parking slot (1 for occupied, 0 for available). You are required to use pointers to manipulate the
array during parking and un-parking operations. Implement user-defined functions for the
following tasks:
1. Allowing a car to enter (assign a free slot).
2. Allowing a car to exit (free the occupied slot).
3. Displaying the current status of all parking slots.
4. Displaying the number of currently available slots.
5. Searching for a car by a unique token/ID (optional simulated feature).
Each parked car should be assigned a unique parking token or ID, which may be generated using
a built-in function such as rand() if applicable.
The application must be menu-driven, utilizing a switch statement to handle the following
options:
1. Park a car
2. Remove a car
3. View parking lot status
4. Display number of available slots
5. Search for car by token/ID
6. Exit
Additionally, the logic should involve at least one instance, each of for, while, and do-while loops
in appropriate parts of the program. The system should validate inputs (e.g., no over-parking, no
removal from an empty or unassigned slot), ensure a modular program structure using functions,
and provide clear and formatted console output for ease of use.
Engr. Eman Fatima