Set - 02 (loops) related problems

Logic Building Set 02

Loop Structures & Iteration
224 Problems

The Loop Masterclass

Mastering iteration is the foundation of computer science. Solve these problems to sharpen your logic.

1
Write a program to print the numbers from 1 to 10 using a loop.
2
Write a program to find the sum of numbers from 1 to 100 using a loop.
3
Write a program to print even numbers from 1 to 20 using a loop.
4
Write a program to print odd numbers from 1 to 20 using a loop.
5
Write a program to print the multiplication table of a number using a loop.
6
Write a program to find the factorial of a number using a loop.
7
Write a program to print a series of Fibonacci numbers using a loop.
8
Write a program to check if a number is prime or not using a loop.
9
Write a program to reverse a number using a loop.
10
Write a program to calculate the sum of digits of a number using a loop.
11
Write a program to print the ASCII values of all alphabets using a loop.
12
Write a program to find the largest element in an array using a loop.
13
Write a program to find the smallest element in an array using a loop.
14
Write a program to count the number of positive and negative numbers in an array using a loop.
15
Write a program to calculate the average of numbers in an array using a loop.
16
Write a program to find the second largest element in an array using a loop.
17
Write a program to find the second smallest element in an array using a loop.
18
Write a program to check if an array is sorted in ascending order using a loop.
19
Write a program to check if an array is sorted in descending order using a loop.
20
Write a program to find the sum of all even numbers in an array using a loop.
21
Write a program to find the sum of all odd numbers in an array using a loop.
22
Write a program to find the product of all elements in an array using a loop.
23
Write a program to find the number of occurrences of an element in an array using a loop.
24
Write a program to remove duplicates from an array using a loop.
25
Write a program to find the largest prime factor of a number using a loop.
26
Write a program to check if a string is a palindrome using a loop.
27
Write a program to find the number of vowels in a string using a loop.
28
Write a program to count the number of words in a sentence using a loop.
29
Write a program to capitalize the first letter of each word in a sentence using a loop.
30
Write a program to reverse a string using a loop.
31
Write a program to check if a number is a perfect number using a loop.
32
Write a program to find the sum of all perfect numbers between 1 and 1000 using a loop.
33
Write a program to find the sum of the squares of all numbers between 1 and 50 using a loop.
34
Write a program to find the sum of the cubes of all numbers between 1 and 50 using a loop.
35
Write a program to convert a decimal number to binary using a loop.
36
Write a program to convert a decimal number to octal using a loop.
37
Write a program to convert a decimal number to hexadecimal using a loop.
38
Write a program to find the LCM of two numbers using a loop.
39
Write a program to find the GCD of two numbers using a loop.
40
Write a program to find the sum of all prime numbers between 1 and 100 using a loop.
41
Write a program to check if a string is a palindrome using a loop.
42
Write a program to count the number of vowels in a string using a loop.
43
Write a program to count the number of words in a sentence using a loop.
44
Write a program to capitalize the first letter of each word in a sentence using a loop.
45
Write a program to reverse a string using a loop.
46
Write a program to check if a number is a perfect number using a loop.
47
Write a program to find the sum of all perfect numbers between 1 and 1000 using a loop.
48
Write a program to find the sum of the squares of all numbers between 1 and 50 using a loop.
49
Write a program to find the sum of the cubes of all numbers between 1 and 50 using a loop.
50
Write a program to convert a decimal number to binary using a loop.
51
Write a program to convert a binary number to decimal using a loop.
52
Write a program to convert a binary number to octal using a loop.
53
Write a program to convert a binary number to hexadecimal using a loop.
54
Write a program to find the factorial of a number using a loop.
55
Write a program to check if a number is an Armstrong number using a loop.
56
Write a program to check if a year is a leap year using a loop.
57
Write a program to print the reverse of a number using a loop.
58
Write a program to find the sum of the digits of a number until the result is a single digit using a loop.
59
Write a program to check if a number is a palindrome using a loop.
60
Print the following star pattern:
* *** ***** ******* *********
61
Print the following pattern:
1 22 333 4444 55555
62
Print the following pattern:
A ABA ABCBA ABCDCBA ABCDEDCBA
66
Write a program to check if a number is a perfect square using a loop.
67
Write a program to find the sum of digits of a factorial using a loop.
68
Write a program to check if a number is a strong number using a loop.
69
Write a program to check if a number is a neon number using a loop.
70
Write a program to find the sum of Fibonacci series using a loop.
71
Write a program to find the sum of all numbers divisible by 3 and 5 between 1 and 100 using a loop.
74
Write a program to check if a number is a happy number using a loop.
75
Write a program to find the HCF (Highest Common Factor) of two numbers using a loop.
77
Write a program to check if a number is a Smith number using a loop.
78
Write a program to find the first n prime numbers using a loop.
82
Write a program to reverse a sentence without reversing the individual words using a loop.
83
Write a program to print the Pascal's triangle using a loop.
89
Write a program to find the sum of the alternate digits of a number using a loop.
102
Write a program to find the GCD (Greatest Common Divisor) of two numbers using recursion and a loop.
113
Write a program to find the factorial of a number using recursion and a loop, without using the * operator.
123
Write a program to find the GCD of two numbers using recursion and a loop, without using the % operator.
138
Write a program to find the sum of the digits of a number using recursion and a loop, using only a single loop and with a time complexity of O(log n).
144
Write a program to find the GCD (Greatest Common Divisor) of two numbers using recursion and a loop, without using the % operator or any library function.
165
Write a program to find the GCD (Greatest Common Divisor) of two numbers using recursion and a loop, without using the % operator or any library function or any additional data structures.
184
Write a program to find the factorial of a number using recursion and a loop, without using the * operator, recursion, or any library function, and with a time complexity of O(n).
186
Write a program to find the GCD (Greatest Common Divisor) of two numbers using recursion and a loop, without using the % operator or any library function or any additional data structures, and with a time complexity of O(log(min(a,b))).
196
Write a program to find the sum of Fibonacci series up to a specific number using recursion and a loop, without using any library function or any additional data structures, and with a time complexity of O(log(n)).
208
Write a program to check if a number is a Smith number using recursion and a loop, without using any library function or any additional data structures, and with a time complexity of O(log(n)^2).
224
Write a program to find the factorial of a number using recursion and a loop, with advanced complexity constraints.
Check the full collection for all 400 algorithmic variants!
Focus on Time Complexity (Big O) for problems 180-224!

Comments

Contact Form

Send

Archive