While Loop Practice Questions (Beginner to
Advanced)
Q1 Print numbers from 1 to 10 using a while loop.
Q2 Print numbers from 10 to 1 using a while loop.
Q3 Print all even numbers from 1 to 20.
Q4 Print all odd numbers from 1 to 20.
Q5 Print the first 10 natural numbers and calculate their sum.
Q6 Print the multiplication table of 5 using a while loop.
Q7 Print the multiplication table of a number entered by the user.
Q8 Print squares of numbers from 1 to 10.
Q9 Print cubes of numbers from 1 to 10.
Q10 Count from 1 to 100 and print only numbers divisible by 5.
Q11 Calculate the sum of numbers from 1 to N.
Q12 Calculate the product of numbers from 1 to N (Factorial).
Q13 Count the number of digits in a number.
Q14 Find the sum of digits of a number.
Q15 Reverse a number.
Q16 Check whether a number is palindrome or not.
Q17 Find the largest digit in a number.
Q18 Find the smallest digit in a number.
Q19 Count how many even digits are present in a number.
Q20 Count how many odd digits are present in a number.
Q21 Keep taking input from the user until they enter 0.
Q22 Keep taking input until the user enters a negative number.
Q23 Ask the user for a password repeatedly until the correct password is entered.
Q24 Create a simple ATM menu using a while loop.
Q25 Create a calculator using a while loop that continues until the user chooses Exit.
Q26 Print star pattern increasing triangle.
Q27 Print star pattern decreasing triangle.
Q28 Print pattern: 1, 12, 123, 1234, 12345.
Q29 Print pattern: 5, 54, 543, 5432, 54321.
Q30 Print pattern: 1, 22, 333, 4444, 55555.
Q31 Find whether a number is Prime using a while loop.
Q32 Print all Prime numbers between 1 and 100.
Q33 Generate Fibonacci series up to N terms.
Q34 Find the GCD of two numbers.
Q35 Find the LCM of two numbers.
Q36 Check whether a number is an Armstrong number.
Q37 Check whether a number is a Perfect Number.
Q38 Find the sum of all digits until a single digit remains.
Q39 Convert a decimal number to binary using a while loop.
Q40 Create a number guessing game using a while loop.
Q41 Print all numbers between 1 and 100 divisible by both 3 and 5.
Q42 Count the number of zeros in a given number.
Q43 Find the second largest digit in a number.
Q44 Check if all digits of a number are even.
Q45 Check if all digits of a number are odd.
Q46 Print numbers from 1 to N without using a for loop.
Q47 Find the frequency of a given digit in a number.
Q48 Remove all zeros from a number.
Q49 Print the reverse multiplication table of a given number.
Q50 Create a menu-driven student management system using a while loop.