w3resource

C Programming Exercises, Practice, Solution : Do While Loop

C Do-While Loop [12 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 1 to 10 and 10 to 1 using a do-while loop.

Click me to see the solution

2. Write a C program that prompts the user to input a series of integers until the user stops by entering 0 using a do-while loop. Calculate and print the sum of all positive integers entered.

Click me to see the solution

3. Write a C program that calculates the sum of even and odd numbers from 1 to 50 using do-while loops.

Click me to see the solution

4. Write a C program that prompts the user to enter a series of numbers until they input a negative number. Calculate and print the sum of all entered numbers using a do-while loop.

Click me to see the solution

5. Write a C program that generates a random number between 1 and 100 and asks the user to guess it. Use a do-while loop to give the user multiple chances until they guess the correct number.

Click me to see the solution

6. Write a C program that prompts the user to enter a positive integer and then calculates and prints the sum of the squares of each digit in that number using a do-while loop

Click me to see the solution

7. Write a C program that calculates the average of a set of numbers input by the user. The user should be able to input as many numbers as desired, and the program should continue until the user decides to stop.

Click me to see the solution

8. Write a C program that prompts the user to enter a password. Use a do-while loop to keep asking for the password until the correct one is entered.

Click me to see the solution

9. Write a C program that calculates and prints the sum of prime numbers up to a specified limit (e.g., 50) using a do-while loop.

Click me to see the solution

10. Write a C program that implements a program to count the number of digits in a given integer using a do-while loop.

Click me to see the solution

11. Write a C program that calculates the compound interest for a given principal amount, interest rate, and time period. Use a do-while loop to allow the user to input values multiple times.

Click me to see the solution

12. Write a C program to reverse a given number using a do-while loop.

Click me to see the solution

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.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/c-programming-exercises/do-while-loop/index.php