0% found this document useful (0 votes)
2 views

Questions on Loops

The document contains a series of programming exercises focused on loops, including for loops, while loops, and do-while loops. It includes tasks such as printing natural numbers, calculating factorials, creating multiplication tables, and using break and continue statements. Additionally, it features exercises on nested loops for pattern printing and generating pairs of numbers.

Uploaded by

gaurav Kurian
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Questions on Loops

The document contains a series of programming exercises focused on loops, including for loops, while loops, and do-while loops. It includes tasks such as printing natural numbers, calculating factorials, creating multiplication tables, and using break and continue statements. Additionally, it features exercises on nested loops for pattern printing and generating pairs of numbers.

Uploaded by

gaurav Kurian
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Questions on Loops

For Loop
1. Write a program to print the first 10 natural numbers using a for loop.
2. Modify the above program to print only the odd numbers from 1 to 20.
3. Write a program to calculate the factorial of a number using a for loop.
While Loop
4. Write a program to print the multiplication table of a given number using a
while loop.
5. Write a program to find the sum of digits of a number using a while loop.
Do-While Loop
6. Write a program to input numbers from the user and calculate their sum.
Stop taking input when the user enters a negative number.
7. Write a program to print numbers from 1 to 10 using a do-while loop.

Questions on break and continue


8. Write a program to print numbers from 1 to 10, but skip the number 5 using
a for loop and continue.
9. Modify the above program to stop printing numbers when the number 5 is
encountered, using a for loop and break.
10. Write a program to find the first number divisible by 7 and 13 between 1 and
100 using a while loop and break.

Questions on Nested Loops


11. Write a program to print the following pattern using nested loops:
*
**
***
****
*****
12. Write a program to print the multiplication table for numbers 1 to 5 using
nested loops.
13. Write a program to print all pairs (i, j) where i and j range from 1 to 3.

You might also like