3. 6=6=6=6= HHHH ==== HHHH EEEE
Definition of leap year:
Rule 1: A year is called leap year if it is divisible
by 400.
For example: 1600, 2000 etc leap year while 1500, 1700
are not leap year.
Rule 2: If year is not divisible by 400 as well as 100
but it is divisible by 4 then that year are also leap
year.
For example: 2004, 2008, 1012 are leap year.
Leap year logic or Algorithm of leap year or Condition
for leap year:
IF year MODULER 400 IS 0
THEN leap_year
ELSE IF year MODULER 100 IS 0
THEN not_leap_year
ELSE IF year MODULER 4 IS 0
THEN leap_year
ELSE
not_leap_year
++++
7 8 !9
:;<
>
:?, E ?;>
:?@ ?= ;>
::: @ AA-; : @ --IA-;;JJ: @ --AA-;;
:?@ ?= ;>
:?@ ?= ;>
->
F
E
, E - -
- -
7. 7 8 ! !9
$ :;
<
=#= = = = >
:;>
:?, =#= ?;>
:?@ @ @ ?= = #= ;>
A#B#H B B >
: 9-;
<
A:H#C : ;;D: B ;>
A:H#H : ;;D: B ;>
:? + , E@ @ ?= = ;>
F
:? ?;>
!:;>
F
!!!!
++++**** $$$$
7 8 !9
7 8 !9
$ :;
<
= A-= >
:;>
:?, ?;>
:?@ ?= ;>
. ! : 9-;
<
A @ ->
A B -C >
A D ->
F
:? $ E@ ?= ;>
!:;>
F
Definition of Armstrong number or what is an Armstrong
number:
Definition according to c programming point of view:
8. Those numbers which sum of the cube of its digits
is equal to that number are known as Armstrong numbers.
For example 153 since 1^3 + 5^3 + 3^3 = 1+ 125 + 9 =153
Other Armstrong numbers: 370,371,407 etc.
In general definition:
Those numbers which sum of its digits to power of
number of its digits is equal to that number are known
as Armstrong numbers.
Example 1: 153
Total digits in 153 is 3
And 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153
Example 2: 1634
Total digits in 1634 is 4
And 1^4 + 6^4 + 3^4 +4^4 = 1 + 1296 + 81 + 64 =1634
Examples of Armstrong numbers: 1, 2, 3, 4, 5, 6, 7, 8,
9, 153, 370, 371, 407, 1634, 8208, 9474, 54748, 92727,
93084, 548834, 1741725
++++ ---- ! " !! " !! " !! " !
7 8 !9
7 8 !9
:;
<
= = = >
:;>
:?G # E?;>
:?@ ?= ;>
A >
A->
. ! : 9-;
<
A @ ->
A C: B B ;>
A D ->
9. F
: AA ;
:?@ K # ?= ;>
:?@ K # ?= ;>
!:;>
F
Definition of prime number:
A natural number greater than one has not any other
divisors except 1 and itself. In other word we can say
which has only two divisors 1 and number itself. For
example: 5
Their divisors are 1 and 5.
Note: 2 is only even prime number.
Logic for prime number in c
We will take a loop and divide number from 2 to
number/2. If the number is not divisible by any of the
numbers then we will print it as prime number.
Example of prime numbers : 2, 3, 5, 7, 11, 13, 17, 19,
23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79,
83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137,
139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193,
197, 199 etc.
++++ ! " !! " !! " !! " !
7 8 !9
7 8 !9
$ :;
<
= = A->
:;>
:? # ?;>
:?@ ?= ;>
. ! :8A ;
<
: @ AA-;
A C >
10. A C >
F
: AA ;
:? @ % ?= ;>
:? @ ?= ;>
F
!:;>
F
++++ ! # . --! # . --! # . --! # . --
DB ! # . --BD
7 8 !9
7 8 !9
$ :;
<
= A >
:;>
. ! : 8A --;
<
A >
. ! :8A ;
<
: @ AA-;
# ">
CC>
F
:AA ;
:?G @ ?= ;>
CC>
F
!:;>
F
++++ ! " . ! ! #! " . ! ! #! " . ! ! #! " . ! ! #
7 8 !9
:;<
=== = A-= >
:?, # E ?;>
:?@ ?= ;>
11. A >
. ! : ;<
A =A >
A @ ->
. ! :8A ;<
A B >
CC>
F
A C >
A D ->
F
: AA ;
:?@ # ?= ;>
:?@ # ?= ;>
->
F
E
, # E %
% #
+ ! " !+ ! " !+ ! " !+ ! " !
7 8 !9
7 8 !9
$ :;
<
="A = >
:;>
:? # ?;>
:?@ ?= ;>
. ! : 8-;
<
: @ "AA-;
"CC>
F
: AA";
:? ?;>
13. A D ->
F
:? ! E@ ?= ;>
!:;>
F
++++
Factorial of number is defined as:
Factorial (n) = 1*2*3 … * n
For example: Factorial of 5 = 1*2*3*4*5 = 120
Note: Factorial of zero = 1
++++ 0000
7 8 !9
7 8 !9
:;
<
== >
:;>
:?G # ?;>
:?@ ?= ;>
A >
A >
. ! :9-;
<
A B >
HH>
F
:? ! @ E@ ?= =;>
!:;>
F
Definition of Palindrome number or what is palindrome
number?
A number is called palindrome number if it is remain
same when its digits are reversed. For example 121 is
palindrome number. When we will reverse its digit it
will remain same number i.e. 121
Palindrome numbers examples: 0, 1, 2, 3, 4, 5, 6, 7, 8,
9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 101, 111, 121,
131, 141, 151, 161, 171, 181, 191 etc.
14. ++++
7 8 !9
7 8 !9
:;
<
= = = >
:;>
:?G # ?;>
:?@ ?= ;>
A >
A->
. ! : 9-;
<
A @ ->
A C: B B ;>
A D ->
F
: AA ;
:?@ K O # ?= ;>
:?@ K # ?= ;>
!:;>
F
Definition of perfect number or what is perfect
number?
Perfect number is a positive number which sum of
all positive divisors excluding that number is equal to
that number. For example 6 is perfect number since
divisor of 6 are 1, 2 and 3. Sum of its divisor
is
1 + 2+ 3 =6
Note: 6 is the smallest perfect number.
Next perfect number is 28 since 1+ 2 + 4 + 7 + 14 = 28
Some more perfect numbers: 496, 8128
15. ++++
7 8 !9
7 8 !9
:;
<
== >
:;>
:?G # ?;>
:?@ ?= ;>
A >
A->
. ! :8 ;
<
: @ AA-;
A C >
CC>
F
: AA ;
:?@ K # ?= ;>
:?@ K # ?= ;>
!:;>
F
OOOO MMMM HHHH !!!!
++++ ! "! "! "! "
7 8 !9
7 8 !9
$ :;
<
= A-= >
:;>
:? ! ?;>
:?@ ?= ;>
<
A @ ->
A B -C >
A D ->
F
. ! : 9-;>
:? ?;>
: AA ;
16. <
:? E@ ?= ;>
F
!:;>
F
++++ ! "! "! "! "
7 8 !9
7 8 !9
$ :;
<
="A >
:;>
:? ?;>
:?@ ?= ;>
<
: @ "AA-;
<
:?6 ?;>
P :-;>
F
"CC>
F
. ! :"8 ;>
:? ?;>
!:;>
F
++++ $$$$
7 8 !9
7 8 !9
$ :;
<
= A-= >
:? ! ?;>
:?@ ?= ;>
<
A @ ->
A B -C >
A D ->
F
20. :?@ ?= ;>
:A-> 8A > CC;
<
A >
A #>
#A C >
:?@ ?= #;>
F
!:;>
F
+ 3 # --+ 3 # --+ 3 # --+ 3 # --
7 8 !9
:;<
== >
= P>
:?, ! E ?;>
:?@ ?= ;>
:?, ! P E ?;>
:?@ ?= P;>
:? # $ E ?;>
: A > 8A P> CC;<
A >
A ->
. ! :8 ;<
: @ AA-;
A C >
CC>
F
: AA ;
:?@ ?= ;>
F
->
F
Sample output:
Enter the minimum range: 1
, ! P E -
# $ E '
21. ++++ ---- ! " !! " !! " !! " !
7 8 !9
:;<
= = = >
= P>
:?, ! E ?;>
:?@ ?= ;>
:?, ! P E ?;>
:?@ ?= P;>
:? # $ E ?;>
: A > 8A P> CC;<
A >
A ->
. ! : IA-;<
A @ ->
A D ->
A C: B B ;>
F
: AA ;
:?@ ?= ;>
F
->
F
++++
BBBB
BBBBBBBB
BBBBBBBBBBBB
BBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBB
7 8 !9
7 8 !9
$ :;
<
= =U>
26. BBBBBBB
BBBBBBBBB
7 8 !9
:;
<
. = = = >
:?, ! # . . ! ?;>
:?@ ?= ;>
A >
: . A > . 8A > . CC ;
<
: A > 8 > CC ;
:? ?;>
HH>
: A > 8A B . H > CC ;
:?B?;>
:?G ?;>
F
->
F
++++ 3333
A B C D E F G H
A B C D E F G
A B C D E F
A B C D E
A B C D
A B C
27. A B
A
7 8 !9
:;
<
! ! A R R>
= ="= A ->
:?@ ?= ;>
:" A > " 9A > "HH ;
<
: A > 8A > CC;
:? ?;>
CC>
: A > 8A " > CC ;
<
:?@ ?= !;>
!CC>
F
:?G ?;>
! A R R>
F
->
F
++++ 3333
1
01
010
1010
10101
7 8 !9
:;
<
= ="= A >
:?@ ?= ;>
: A > 8A > CC ;
28. <
:" A > " 8A > "CC ;
<
:?@ ?= ;>
: AA - ;
A >
A ->
F
:?G ?;>
F
->
F
++++ 3333
p
pr
pro
prog
progr
progra
program
7 8 !9
7 8 !9
:;
<
! W --X>
="= !>
:?, G ?;>
: ;>
! A : ;>
: A - > 8 ! > CC ;
<
:" A - > " 8A > "CC ;
<
:?@ ?= W"X;>
F
:?G ?;>
F
->
F
29. ++++ 3333
1
121
12321
1234321
123454321
7 8 !9
:;
<
= ="=P A >
:?@ ?= ;>
: A > 8A > CC ;
<
:" A > " 8A > "CC ;
<
:?@ ?=P;>
PCC>
F
PHH>
:" A > " 8A H > "CC ;
<
PHH>
:?@ ?=P;>
F
:?G ?;>
P A >
F
->
F
++++ 3333 $ !$ !$ !$ !
DBBBBBBBB APCPY D ICPY D IC PY D IBD
7 8 !9
7 8 !9
7 8 ! !9
$ :;
<
A ==P== >
>
:;>
30. :?, ! $ ?;>
:?@ ?= ;>
:?, ! $ P?;>
:?@ ?= P;>
AP>
:A > 8A > CA ;
<
A >
:A > 8A > CC;
A B >
A C . :P=;D>
F
:?G E@ ?= ;>
!:;>
F
++++ 3333 $ !$ !$ !$ !
DBBBBBBBB A D Y C D Y C D Y CCCCCCCCCCC D Y BD
7 8 !9
7 8 !9
7 8 ! !9
$ :;
<
== >
P= >
:;>
:?, ! $ ?;>
:?@ ?= ;>
:A > 8A > CC;
<
PAPC . := ;>
A C . := ;>
F
:?G PE@ =G E@ ?=P= ;>
!:;>
F
31. ZO Q 3 5 K 5 SZO Q 3 5 K 5 SZO Q 3 5 K 5 SZO Q 3 5 K 5 SHHHH
3 5 K 6K O , E3 5 K 6K O , E3 5 K 6K O , E3 5 K 6K O , E HHHH
7 8 !9
7 8 !9
7 8 ! !9
$ :;
<
== >
P= >
:;>
:A > 8A -> CC;
<
:@ AA-;
>
:?G @ ?=;>
F
!:;>
F
& 5 5& 5 5& 5 5& 5 5 EEEE HHHH
7 8 !9
7 8 !9
7 8 ! !9
$ :;
<
= = A->
:;>
:?, ! $ ?;>
:?@ ?= ;>
$E
: AA-;
:?@ ?= ;>
<
A @ ->
A B -C >
A D ->
$>
F
!:;>
F
& 5 5& 5 5& 5 5& 5 5 EEEE HHHH
7 8 !9
7 8 !9
7 8 ! !9
$ :;
<
32. >
:;>
:?, ! $ ?;>
:?@ ?= ;>
: @ AA-;
$ >
>
$ E :?, $ ?;>
>
E :? ?;>
E
:?G @ ?= ;>
!:;>
F