0% found this document useful (0 votes)
17 views2 pages

Looping Questions

The document contains 30 problems related to loops in programming. Some problems involve printing numbers in various sequences, calculating sums and products, checking properties of numbers like primality and palindromicity, generating Fibonacci sequences and factorials, and more. Multiple problems involve accepting user input for parameters like upper and lower bounds and using loops to process the numbers within the given ranges.

Uploaded by

AGNEE MOHANTY
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

Looping Questions

The document contains 30 problems related to loops in programming. Some problems involve printing numbers in various sequences, calculating sums and products, checking properties of numbers like primality and palindromicity, generating Fibonacci sequences and factorials, and more. Multiple problems involve accepting user input for parameters like upper and lower bounds and using loops to process the numbers within the given ranges.

Uploaded by

AGNEE MOHANTY
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Problems in loop

1. Accept ‘n’, print from 1 to n


2. Accept ‘n’, print from n to 1
3. Accept ‘m’ and ‘n’, print from ‘m’ to ‘n’, forward and reverse.
4. Accept ‘n’,
a. print all even numbers from 1 to ‘n’
b. print all odd numbers from 1 to ‘n’
5. Accept ‘n’, print sum of all numbers from 1 to ‘n’
6. Accept ‘n’, print product of all numbers from 1 to ‘n’/ factorial of n
7. Accept ‘n’
a. print Fibonacci of all numbers from 1 to ‘n’
b. print ‘n’ Fibonacci numbers
8. Accept base ‘x’ and exponent ‘n’, print xn
9. Accept two numbers, print GCD/HCF and LCM.
10. Accept a number ‘n’
a. check it is prime number or not
b. generate all prime number within the range 1-n
c. print all factors of n
d. print all prime factors of n
11. Keep on accepting number till user wises, print the maximum, second maximum, minimum,
second minimum when he stops.
12. Keep on accepting a number and print the same till user enters 99
13. Accept a multi-digit number
a. print the number of digits
b. reverse the number
c. check whether a number is palindrome
d. check whether the number is Armstrong number or not
14. Accept a number ‘n’
a. print multiplication table of ‘n’
b. print multiplication table till ‘n’

15. 16. 17.


* 1 1
* * 1 2 2 2
* * * 1 2 3 3 3 3
* * * * 1 2 3 4 4 4 4 4

18. 19. 20.


1 1 1
2 3 1 2 1 2 1
4 5 6 1 2 3 1 2 3 2 1
7 8 9 10 1 2 3 4 1 2 3 4 3 2 1

21. 22. 23.


1 1
1 2 1
1 2 3 2 1 1 1 0 1
1 2 3 4 3 2 1 1 1 1 0 0 0 1
1 2 3 2 1
1 2 1 1 1 1 1 1 1 1 1 1
1
1 1 1 1

24. 25. 26.

1 1 1 1 1 2
1 2 3 2 4 3 2 2 2
1 2 3 4 5 3 6 9 3 3 3 4
1 2 3 4 8 12 16 5 4 4 4
1

27. 28. for n=4 29.

0 1 1 * 2 * 3 * 4 * 17 * 18 * 18 * 20
1 0 3*2 5 * 6 * 7 * 14 * 15 * 16
0 1 0 4*5*6 8 * 9 * 12 * 13
1 0 1 0 10 * 9 * 8 * 7 10 * 11

30.
A Pythagorean triplet is a set of three integers a, b, and c such that a2 + b2 =c2. Given a limit,
generate all Pythagorean triplets with a value smaller than the limit.
Input: limit = 20
Output:
3 4 5
8 6 10
5 12 13
15 8 17
12 16 20

You might also like