Logical Questions
Logical Questions
A company has implemented a multi-level access control system for employees. The access
is determined based on:
Task:
1. Asks the user to input their role (1-4) and password.
2. Checks if the password is correct (for simplicity, assume password = 1234 for all
roles).
3. Validates whether the user can enter based on their role, time, and weekday/weekend.
4. If the user enters the wrong password three times, deny further access.
Hints:
Task:
1. Takes number of questions, answered questions, timer (minutes left), and login
attempt status (0 or 1 for multiple logins) as input.
2. Checks conditions and decides if the student can submit, needs approval, is
auto-submitted, or is disqualified.
Hints:
A restaurant billing system allows customers to place orders using item codes. Each item
has a fixed price:
1 Burger 5.99
2 Pizza 8.49
3 Pasta 6.99
4 Coffee 2.99
5 Juice 3.49
● If the total bill is $20 or more, the customer gets a 10% discount.
● If the customer orders more than 5 items, they get a free coffee.
● If the total bill is $50 or more, they get a 15% discount.
Task:
● Employees work for 5 days a week, with 8 hours per day as standard working
hours.
● If an employee works more than 8 hours in a day, the extra hours are considered
overtime.
● Overtime pay is 1.5 times the regular hourly rate.
● If an employee works for less than 5 days, a 20% salary deduction is applied.
● The hourly rate is $20 per hour.
Task:
1. Takes the number of days worked and daily working hours as input.
2. Uses a for loop to calculate the total salary, including overtime pay.
3. Applies deductions if the employee worked less than 5 days.
Hints:
Task:
Hints:
A simple number guessing game where the user must guess a randomly generated number
between 1 and 100.
● The user gets unlimited attempts but must guess within 10 tries to win.
● After each guess, the program should give hints:
○ "Too high!" if the guess is greater than the target number.
○ "Too low!" if the guess is lower than the target number.
● If the user fails within 10 attempts, they lose the game.
Task:
Hints:
Task:
1. Uses a for loop to validate each character of the entered password.
2. Uses a while loop to keep asking for a password until a valid one is entered.
Hints:
A company maintains a list of employees based on their joining order. However, due to a
shift change, the list needs to be rotated.
Task:
Example:
Constraints:
A teacher wants to analyze student test scores. You are given an array of test scores, and your
task is to find how many times each unique score appears.
Task:
Example:
Input: arr[] = {90, 85, 90, 78, 85, 85, 92}
Output:
90 → 2 times
85 → 3 times
78 → 1 time
92 → 1 time
Constraints:
A developer needs a system to quickly calculate the sum of each row and column in a 2D
matrix.
Task:
Example:
Input:
Matrix =
1 2 3
4 5 6
7 8 9
Output:
Row Sums: 6, 15, 24
Column Sums: 12, 15, 18
Constraints:
● The program should work for any NxM matrix, not just 3x3.
● The functions must not modify the original matrix.
You need to swap two integer pointers without using a temporary variable.
Task:
● Write a function swapPointers(int *a, int *b) that swaps two integer pointers
without using a third pointer.
● Call the function from main() and print the values before and after swapping.
Example:
Constraints:
Write a program that dynamically allocates an array, fills it with user input, and then
reverses it using only pointers.
Task:
Example:
Input: arr[] = {1, 2, 3, 4, 5}
Output:
Before: 1 2 3 4 5
After: 5 4 3 2 1
Constraints:
Write a program that sorts an array in either ascending or descending order, depending
on the function pointer passed.
Task:
Constraints:
A company stores employee details, including personal information and job details,
using nested structures.
Task:
Example:
Input:
Name: John Doe, ID: 101, Salary: 50000, Designation: Manager, Experience: 5 years
Output:
Employee ID: 101
Name: John Doe
Salary: 50000
Designation: Manager
Experience: 5 years
Constraints:
A university tracks student scores and determines their grades based on the average
score.
Task:
Input:
John, Roll: 101, Marks: {85, 90, 78, 92, 88}
Output:
Name: John
Roll No: 101
Average: 86.6
Grade: B
Constraints:
Task:
Example:
Input:
Patient 1: John, Age: 45, Disease: Flu, Admission Date: 12-01-2024
Patient 2: Alice, Age: 30, Disease: Fever, Admission Date: 15-01-2024
Output:
Patient Name: John
Age: 45
Disease: Flu
Admission Date: 12-01-2024
Constraints: