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

Exercise While Loop Java

The document outlines 10 programming exercises to practice using while loops in different scenarios. The exercises include printing numbers from 1 to 10, calculating factorials, finding digit sums, reversing numbers, printing even numbers from 1 to 50, checking for palindromes, calculating the Fibonacci sequence, checking for prime numbers, generating multiplication tables, and creating a password guessing game loop.

Uploaded by

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

Exercise While Loop Java

The document outlines 10 programming exercises to practice using while loops in different scenarios. The exercises include printing numbers from 1 to 10, calculating factorials, finding digit sums, reversing numbers, printing even numbers from 1 to 50, checking for palindromes, calculating the Fibonacci sequence, checking for prime numbers, generating multiplication tables, and creating a password guessing game loop.

Uploaded by

Flori Moise
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Exercise 1: Print Numbers from 1 to 10 Write a program that uses a while loop to print

numbers from 1 to 10.

Exercise 2: Calculate Factorial Write a program to calculate the factorial of a number


entered by the user using a while loop.

Exercise 3: Find the Sum of Digits Create a program that calculates the sum of digits in a
given number using a while loop.

Exercise 4: Reverse a Number Write a program to reverse a number using a while loop.

Exercise 5: Print Even Numbers Print all even numbers from 1 to 50 using a while loop.

Exercise 6: Check for Palindrome Create a program that checks if a given number is a
palindrome (reads the same backward) using a while loop.

Exercise 7: Calculate the Fibonacci Sequence Write a program to generate the first n
Fibonacci numbers using a while loop.

Exercise 8: Prime Number Checker Create a program that checks if a given number is
prime or not using a while loop.

Exercise 9: Print Multiplication Table Generate the multiplication table of a number


entered by the user using a while loop.

Exercise 10: Password Guessing Game Write a simple password guessing game using a
while loop. The program should keep asking the user for a password until they enter the
correct one.

You might also like