9th programs-conditional and iterative
9th programs-conditional and iterative
2.Reverse of a number
Eg:=Input :123
Output :321
4.Spy number or not(sum of the digit is equal to product of the digit eg:=1124=1+1+2+4=8
and 1*1*2*4=8)
5.perfect number or not(Number which is equal to the sum of its factors other the number
itself.
Eg : 6=1+2+3
6.Palindrome or not(Number that remains same when its digit s are reversed.)
8. composite number or not(number has one or more than one factors excluding 1 and
number itself)
14.Write a program to input a number .Find the difference between highest and smallest
number. .(eg : input : 5134 ,output : 5-1=4)
16. A Dudeney number is a positive integer that is a perfect cube such that the sum of its
digits is equal to the cube root of the number. Write a program to input a number and check
and print whether it is a Dudeney number or not.
Example:
Consider the number 512.
Sum of digits = 5 + 1 + 2 = 8
Cube root of 512 = 8
As Sum of digits = Cube root of Number hence 512 is a Dudeney number.
18. Write a program to enter 10 numbers and check whether they are divisible by 5 or not
.If divisible the perform the following tasks.
a. Display all the numbers ending with the digit 5
b .Count the numbers ending with 0
19. A tech number has even number of digits. If the number is split in two equal halves, then
the square of sum of these halves is equal to the number itself. Write a program to generate
and print all four digits tech numbers.
Example:
Consider the number 3025
Square of sum of the halves of 3025 = (30 + 25)2
= (55)2
= 3025 is a tech number.
20.Write a program to input any 50 numbers (including negative and positive )and perform
the following task.
a. Count the positive numbers
b. Count the negative numbers
c. sum of positive numbers
d. sum of negative numbers
21.Amstrong number or not(A number is called Armstrong number if the following equation
holds true for that number: xy..z = xn+yn+……..+zn where n denotes the number of digits in
the number)
22.A disarium number is a number where the sum of the digits raised to the power of their
respective position is equal to the number itself. For example, 135 is a disarium number because 135
= 11 + 32 + 53
23. A number is said to be Peterson if the sum of factorials of each digit is equal to the sum
of the number itself.
Suppose, we have to check the number (n) 145 is Peterson or not.
Number = 145
145 = !1 + !4 + !5
=1+4*3*2*1+5*4*3*2*1
=1+24+120
145=145
24.A number is called a tech number if the given number has an even number of digits and
the number can be divided exactly into two parts from the middle. After equally dividing the
number, sum up the numbers and find the square of the sum. If we get the number itself as
square, the given number is a tech number, else, not a tech number.
For example, 3025 is a tech number.
25.A positive integer whose sum of digits of its square is equal to the number itself is called
a neon number.
1 2 3 n
2. 𝑠 = + + + ⋯+
𝑥 𝑥2 𝑥3 𝑥𝑛
1 2 3 49
4. 𝑠 = + + + ⋯
2 3 4 50
𝑎 𝑎 𝑎 𝑎
5. 𝑠 = 𝑎 + + + +⋯
2 3 4 𝑛
1 2 3 10
7. S= + + +⋯
√1 √2 √3 √10
𝑎2 𝑎2 𝑎2 𝑎2
8. 𝑠 = 𝑎2 + + + +⋯
2 3 4 10
𝑎2 𝑎3 𝑎10
9. 𝑠 = a + + +⋯
2 3 10
12 22 33
10. 𝑠 = + 2
+ + ⋯ 𝑡𝑜 𝑛 𝑡𝑒𝑟𝑚𝑠
𝑎 𝑎 𝑎3
12 32 52
11. 𝑠 = + 2
+ … 𝑡𝑜 𝑛 𝑡𝑒𝑟𝑚𝑠
𝑎 𝑎 𝑎3
𝑎 𝑎 𝑎 𝑎 a
12. 𝑠 = + + + …+
2 5 8 11 20
13. S= 2 - 4 + 6 - 8+ …… -20
14. S= 1 + 4 + 9+ ………400
x x x x x
16. S = + + + + …… +
2 5 8 11 20
19. s=1!+2!+3!+….+n!
20. s=x/1+x/2+x/3+x/4+…..x/n
1. 1,4,9,16,…………………………….
2. 1,2,4,7,11,………………………
3. 3,6,9,12,…………………………..
4. 4,8,16,32,…………………………..
5. 1.5,3.0,4.5,6.0,…………………
6. 0,7,26,……………….
7. 1,9,25,49,…………………… .
8. 4,16,36,64,………………. .
9. 0,3,8,15,……….. .
10. 24,99,224,399………….. .
11. 2,5,10,17……………………. .
12. 1,-3,5,-7……………n terms
13.
5 1 2 3 4 5
5 4 3 2 1 5 4 1 2 3 4
4 3 2 1 5 4 3 1 2 3
3 2 1 5 4 3 2 1 2
2 1 5 4 3 2 1 1
1
A A B C D E F
A B B A B C D E
A B C C C A B C D
A B C D D D D A B C
A B C D E E E E E A B
A B C D E F F F F F F A
A B C D E F
5 5 5 5 5 1 1 3 5 7 9
4 4 4 4 4 2 1 1 3 5 7
3 3 3 3 3 3 2 1 1 3 5
2 2 2 2 2 4 3 2 1 1 3
1 1 1 1 1 5 4 3 2 1 1
9 9 9 9 9 9 9
7 7 7 7 7 7 9 9 7
5 5 5 5 5 5 7 9 9 7 5
3 3 3 3 3 3 5 7 9 9 7 5 3
1 1 1 1 1 1 3 5 7 9 9 7 5 3 1
1 * * * * 1 * * * * *
* 2 * * * 2 2 * * * * #
* * 3 * * 3 3 3 * * * # *
* * * 4 * 4 4 4 4 * * # * #
* * * * 5 5 5 5 5 5 * # * # *
* * * * * 5 1 2 3 4 5
* * * * * 4 1 2 3 4
# # # * * 3 1 2 3
* * * * * 2 1 2
# # # # # 1 1
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2
2 3 44
4 5 6
7 8 9 10
666
11 12 13 14 8888
15 16 17 18 19 10 10 10 10 10