C Programming Exercises, Practice, Solution : While Loop
This resource offers a total of 55 C While Loop problems for practice. It includes 11 main exercises, each accompanied by solutions, detailed explanations, and four related problems.
[An Editor is available at the bottom of the page to write and execute the scripts.]
1. Print Numbers Using Two While Loops
Write a C program to print numbers from 0 to 10 and 10 to 0 using two while loops.
2. Sum of Positive Integers Until 0
Write a C program that prompts the user to input a series of integers until the user stops entering 0 using a while loop. Calculate and print the sum of all the positive integers entered.
3. Product of Numbers from 1 to 5
Write a C program that calculates the product of numbers from 1 to 5 using a while loop.
4. Input Until Duplicate Number
Write a C program that prompts the user to input a series of numbers until they input a duplicate number. Use a while loop to check for duplicates.
5. Random Number Guessing Game
Write a C program that generates a random number between 1 and 20 and asks the user to guess it. Use a while loop to give the user multiple chances until they guess the correct number.
6. Factorial Calculation Using a While Loop
Write a C program that prompts the user to enter a positive integer. It then calculates and prints the factorial of that number using a while loop.
7. Username Validation Using a While Loop
Write a C program that prompts the user to input a username. Use a while loop to keep asking for a username until a valid one is entered (e.g., at least 8 characters long).
8. Sum of Cubes of Even Numbers Up to a Limit
Write a C program that calculates and prints the sum of cubes of even numbers up to a specified limit (e.g., 20) using a while loop.
9. Palindrome Number Check Using a While Loop
Write a C program that implements a program to check if a given number is a palindrome using a while loop.
10. Fibonacci Sequence Generation Using a While Loop
Write a C program to find and print the first 10 Fibonacci numbers using a while loop.
11. Multiplication Table Using a While Loop
Write a C program that prompts the user to enter a positive integer. Use a while loop to print the multiplication table for that number up to 10.
C Programming Code Editor:
More to Come !
Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics