Skip to content

Latest commit

 

History

History
358 lines (236 loc) · 3.47 KB

07-loop-exercise.md

File metadata and controls

358 lines (236 loc) · 3.47 KB

For Loop Exercise

Question 1

Print 1 to 100.

Question 2

Print all Odd numbers from 1 to 100.

Question 3

Print all Even numbers from 1 to 100.

Question 4

Print all numbers which are divisible of 5 in 1 to 100.

Question 5

Print all numbers which are divisible of 5 and 15 in 1 to 100.

Question 6

Print 2's table.

Question 7

Ask user a question "How many times do you want to print Hello World?" and then print Hello World that number of times.

Question 8

Calculate sum of all numbers from 1 to 100.

Question 9

Calculate sum of all odd numbers from 1 to 100.

Question 10

Calculate sum of all even numbers from 1 to 100.

Question 11

Print 1,2,4,8,16,32,64.......upto 2048.

Question 12

Print

1,2,3,4,5,6,7,8,9,10
11,12,13,14,15,16,17,18,19,20
.
.
......................99,100

Question 13

Print 1 to 100, but with a specific condition. If a number is divisible by both 3 and 5, it logs "fizzbuzz" to the console instead of the number itself.

Question 14

print 10's table like this


2*1=2
2*2=4
2*3=6
2*4=8
2*5=10
.
.
.
2*10=20

Question 15

Run a loop from 1 to 50

From 1 to 10 print "A"
From 11 to 20 print "B"
From 21 to 30 print "C"
From 31 to 40 print "D"
From 41 to 50 print "E"

Question 16

Run a loop from 50 to 1

From 50 to 41 print "A"
From 40 to 31 print "B"
From 30 to 21 print "C"
From 20 to 11 print "D"
From 10 to 1 print "E"

Question 17

Print below series:

5 25 125.. till number is less than equal to 10000

Question 18

Print below series:

3,6,9,12... till number is less than equal to 500

Question 19

Print below series:


120
221
322
423
524
625
726
827
928
1029

Question 20

Print below series:

100 95 90 85 80 ... till 0

Question 21

Number 70 is divisible by which numbers till 70? Find out and print those numbers.

while loop Exercise

Question 22

Write a while loop that logs the numbers 1 to 10 in the console.

Question 23

Calculate sum of all numbers from 1 to 10.

Question 24

Counting down from 10 to 1.

Question 25

Print 2's table.

Question 26

Calculate sum of all odd numbers from 1 to 100.

do while loop

Question 27

Write a do...while loop that logs the numbers 1 to 5 in the console.

Question 28

Counting down from 10 to 1.

Question 29

Calculate sum of all numbers from 1 to 10.

Question 30

Print 2's table.

Question 31

Ask user a question "How many times do you want to print Hello World?" and then print Hello World that number of times.

Question 32

Calculate sum of all even numbers from 1 to 100.

Pattern questions

Question 33

Print pattern


1
11
111
1111
11111

Question 34

Print Pattern

---

---

---

Question 35

Print pattern

***
***
***
***

Question 36

Print Pattern

12345
1234
123
12
1

Question 37

Print pattern

54321
5432
543
54
5

Question 38

Print pattern

54321
4321
321
21
1

Question 39

Print pattern

$$
$$

$$
$$

$$
$$

Question 40

Print pattern

*****
****
***
**
*
*
**
***
****
*****

Question 41

Print pattern

10987654321
987654321
87654321
7654321
654321
54321
4321
321
21
1

Question 42

Print pattern

*
**
***
****
*****
****
***
**
*

Question 43

Print pattern

*********
 *******
  *****
   ***
    *

Question 44

Print Pattern

     *
    ***
   *****
  *******
 *********
***********