0% found this document useful (0 votes)
0 views4 pages

for loop

The document outlines a series of programming exercises categorized into beginner and intermediate levels, focusing on basic operations such as printing numbers, calculating sums, and checking properties of numbers. It includes tasks like printing even and odd numbers, calculating factorials, and checking for prime numbers. Additionally, there are challenge questions that test skills in finding digits and checking for palindromes.

Uploaded by

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

for loop

The document outlines a series of programming exercises categorized into beginner and intermediate levels, focusing on basic operations such as printing numbers, calculating sums, and checking properties of numbers. It includes tasks like printing even and odd numbers, calculating factorials, and checking for prime numbers. Additionally, there are challenge questions that test skills in finding digits and checking for palindromes.

Uploaded by

lubana576973
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Beginner Level

1. Print Numbers

Print numbers from 1 to 10 using a for loop.

2. Print Even Numbers

Print all even numbers from 1 to 20.

3. Print Odd Numbers

Print all odd numbers from 1 to 20.

4. Sum of First N Numbers

Take n as input and find the sum of numbers from 1 to n.

5. Multiplication Table

Take a number as input and print its multiplication table up to 10.

Example:

Input: 5

Output:
5x1=5
5 x 2 = 10
...
5 x 10 = 50

6. Count Digits

Take a number and count how many digits it contains using a loop.

7. Sum of Digits

Take a number and find the sum of its digits.

Example:

Input: 1234
Output: 10
Intermediate Level
8. Factorial of a Number

Find the factorial of a given number.

Example:

Input: 5
Output: 120

9. Reverse a Number

Take a number and print it in reverse order.

Example:

Input: 1234
Output: 4321

10. Check Prime Number

Check whether a given number is prime or not.

11. Find Factors

Print all factors of a given number.

Example:

Input: 12
Output: 1 2 3 4 6 12

12. Sum of Even Numbers

Find the sum of all even numbers between 1 and n.

13. Fibonacci Series

Print first n terms of Fibonacci series.

Example:

Input: 6
Output: 0 1 1 2 3 5

14. Armstrong Number


Check whether a number is Armstrong or not.

Example:

153 = 1³ + 5³ + 3³

15. Strong Number

Check whether a number is a Strong Number.

Example:

145 = 1! + 4! + 5!

21. Prime Numbers in Range

Print all prime numbers between 1 and n.

22. Perfect Number

Check whether a number is perfect or not.

Example:

6=1+2+3

23. GCD of Two Numbers

Find the Greatest Common Divisor using loops.

24. LCM of Two Numbers

Find the Least Common Multiple using loops.

29.. Count Prime Digits

Take a number and count how many digits are prime (2, 3, 5, 7).

Example:

Input: 23579
Output: 4

30. Frequency of Digits

Take a number and print frequency of each digit.

Example:

Input: 112233
Output:
1 -> 2
2 -> 2
3 -> 2

Challenge Questions (Interview Style)

33.

Find the largest digit in a number.

34.

Find the second largest digit in a number.

35.

Check whether a number is palindrome or not.

Example:

121 → Palindrome
123 → Not Palindrome

You might also like