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

Programs Control Flow

Uploaded by

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

Programs Control Flow

Uploaded by

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

Practice Problems Based on Control Structures in Java

Here’s a curated list of problems to help you practice control structures effectively:

1. Decision-Making Problems (if, if-else, switch)

1. Check if a number is positive, negative, or zero.


2. Find the largest of three numbers.
3. Check if a year is a leap year.
4. Menu-driven program for a simple calculator using switch.
5. Check if a character is a vowel or consonant.
6. Determine the grade of a student based on marks.

2. Loop Problems (for, while, do-while)

1. Print all even numbers from 1 to 100.


2. Calculate the sum of the first N natural numbers.
3. Find the factorial of a number.
4. Reverse a given number (e.g., 123 → 321).
5. Check if a number is a palindrome.
6. Generate the multiplication table for a given number.
7. Find the GCD (Greatest Common Divisor) of two numbers.

3. Nested Loop Problems

1. Print a simple pyramid pattern.


2. *
3. * *
4. * * *
5. Print an inverted triangle pattern.
6. * * * *
7. * * *
8. * *
9. *
10. Generate a number triangle pattern.
11. 1
12. 1 2
13. 1 2 3

4. Problems Combining Decision-Making and Loops


1. Print all prime numbers between 1 and 100.
2. Check if a number is Armstrong (e.g., 153 = 1³ + 5³ + 3³).
3. Check if a number is perfect (e.g., 6 = 1 + 2 + 3).
4. Find the sum of digits of a number (e.g., 123 → 1 + 2 + 3 = 6).

5. Mixed Control Flow Challenges

1. Menu-driven program to perform different mathematical operations (factorial,


GCD, power, etc.).
2. Generate Fibonacci series up to N terms.
3. Simulate a basic ATM program:
o Withdraw, deposit, and check balance.
4. Find the LCM of two numbers using loops and conditions.

Would you like detailed solutions or hints for any specific problem?

You might also like