Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

THIAGARAJAR POLYTECHNIC COLLEGE, SALEM - 636005

| Govt Aided | Autonomous | NBA Accredited: Civil, Mech, EEE, Prodn. & Textile Tech Programmes |
CONTINUING EDUCATION CENTRE

While Loop in C Programming Exercises

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.

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.

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

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.

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.

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.

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

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.

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

You might also like