The document outlines a series of programming assignment questions focused on control structures for a lab module in the Department of Computer Science at IIUI. It includes tasks related to conditional statements, switch statements, and loops, requiring students to implement various programs such as checking even/odd numbers, calculating grades, and creating a basic calculator. The assignments are due by April 28, 2025, and are intended for the BSIT-F24-A class in Spring 2025, taught by Mr. Jahanzaib Ali Khan.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
14 views3 pages
Mahtab Assignment
The document outlines a series of programming assignment questions focused on control structures for a lab module in the Department of Computer Science at IIUI. It includes tasks related to conditional statements, switch statements, and loops, requiring students to implement various programs such as checking even/odd numbers, calculating grades, and creating a basic calculator. The assignments are due by April 28, 2025, and are intended for the BSIT-F24-A class in Spring 2025, taught by Mr. Jahanzaib Ali Khan.
1. Write a program to check whether a given number is even or odd using a
nested if statement. 2. Develop a program that takes a student’s marks as input and assigns a grade based on the following: o 90-100 → A o 80-89 → B o 70-79 → C o 60-69 → D o Below 60 → F 3. Write a program that checks whether a given year is a leap year or not using if-else conditions. 4. Implement a program to find the largest of three numbers using an if-else- if structure. 5. Write a program that asks the user for their ATM PIN. If the PIN is correct, allow withdrawal; otherwise, display an error message. If the withdrawal amount exceeds the balance, show "Insufficient balance". Use a nested if statement. 6. Create a program that calculates the electricity bill based on the following conditions:
1 - 100 units → 5 Rs. per unit
101 - 300 units → 7 Rs. per unit Above 300 units → 10 Rs. per unit 11.Develop a program that checks whether a person is eligible to vote or not based on their age. If the person is above 65, recommend senior citizen benefits. 12.Write a program that calculates the income tax for a person based on their annual income using an if-else-if structure.
Switch Statement Problems
13.Write a program using a switch statement to implement a basic calculator
that performs addition, subtraction, multiplication, and division based on user input. 14.Develop a program that takes a day number (1-7) as input and displays the corresponding weekday name using a switch statement. 15.Implement a program using switch to convert a character into uppercase, lowercase, or check if it’s a digit based on user input. 16.Create a program that takes a month number (1-12) as input and outputs the number of days in that month using a switch statement. 17.Write a program that takes a menu option (1-5) from the user and performs the corresponding food ordering operation using a switch statement. 18.Develop a switch-based program that checks vowel and consonant by taking a single character as input and determining whether it is a vowel or consonant.
Loops (for, while, do-while)
19.Write a program using a for loop to display the multiplication table of a
number entered by the user. 20.Develop a program that calculates the sum of all even numbers between 1 and N using a for loop. 21.Write a program using a while loop to reverse a number entered by the user. 22.Create a program using a while loop to check if a number is palindromic (e.g., 121 is a palindrome, 123 is not). 23.Write a program using a do-while loop that continuously asks the user to enter a number until they enter a negative number. 24.Implement a program using a for loop to print the Fibonacci sequence up to N terms. 25.Write a program using a while loop to find the factorial of a number. 26.Develop a program using a for loop to check if a number is prime. 27.Write a program that takes a number as input and prints its digits in reverse order using a while loop. 28.Implement a program that uses a do-while loop to create a simple login system where the user is repeatedly asked to enter a password until they enter the correct one. 29.Write a program using nested loops to print the following pattern for N rows: