Monday 3 August 2015

Loops


Iteration through loops (Nested)


This Page contains the practice questions based on nested loops for Class IX and X Students. Feel Free to ask your query if any problem occurs in solving any of the question.

1. WAP to gererate all perfect numbers between 1 to 100. (Perfect numbers are those numbers for which the sum of factors of the number is equal to the number.)

2. WAP to generate all prime numbers between 50 to 500.

3. WAP to generate all twin prime numbers between 1 to 1000. (The prime numbers whose difference is two, are said as twin prime numbers. E.g. (3,5), (5, 7), (11, 13) (17, 19).

4. WAP to calculate the squares of all the numbers between 1 to 100 without using any in-built function.

5. WAP to generate the following formats :
a. 1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

b. 5
5 4
5 4 3
5 4 3 2
5 4 3 2 1

c. 9 8 7 6 5
9 8 7 6
9 8 7
9 8
9

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

e.           9
        9 8
     9 8 7
  9 8 7 6
9 8 7 6 5

f.          1
2 1
3 2 1
4 3 2 1
5 4 3 2 1

g.
4 5 
3 4 5
2 3 4 5
1 2 3 4 5

h. 9 8 7 6 5
8 7 6 5
7 6 5
6 5
5

i. 1
2 3
4 5 1
2 3 4 5

j.           9
        8 9
     7 8 9
  6 7 8 9
5 6 7 8 9

k. 1
2 3
4 5 1
2 3 4 5
     1 2 3 4 5

6. WAP to find the sum of following serieses:

a)

b)

c)

d)


7. WAP to print the following formats :
a. #
* *
! ! !
~ ~ ~ ~
$ $ $ $ $

b. 9
8 8
7 7 7
6 6 6 6
5 5 5 5 5

c.      *
       *  *
   *  *  *
     *  *
       *

d. 1
3 3 3
5 5 5 5 5
7 7 7 7 7 7 7
5 5 5 5 5
3 3 3
1

e. $ $ $ $ $
$ $ $
$
$ $ $
$ $ $ $ $
Free Web Counter
Free Web Counter
 
;