C Programming Exercises, Practice, Solution : While Loop
C While Loop [11 exercises with solution]
[An editor is available at the bottom of the page to write and execute the scripts. Go to the editor]
1. Write a C program to print numbers from 0 to 10 and 10 to 0 using two while loops.
2. 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. Write a C program that calculates the product of numbers from 1 to 5 using a while loop.
4. 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. 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. 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. 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. 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. Write a C program that implements a program to check if a given number is a palindrome using a while loop.
10. Write a C program to find and print the first 10 Fibonacci numbers using a while loop.
11. 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