## Explanation:

User enters a number, IF number is divisible by 2 i.e.  if(number % 2==0), then number is even otherwise odd.

## C++ Program to Check Palindrome Number

### Explanation:

• User enters a number ‘n’.
• Save that number ‘n’ to ‘old_num’.
• Find reverse of ‘n’ by taking the remainder ‘num’ and add it to (num*10). Example: if remainder of 151 is 1 we make new number with remainder 1 multiplying it by 10 i.e. 1*10+1=11.
• And dividing ‘n’ by 10 while (n>0).
• Finally by checking the ‘reverse’ with ‘old-num’, we can find whether the given number is palindrome or not.

## Program to Print Fibonacci Series in C++

### What is Fibonacci Series?

In mathematics, the Fibonacci numbers or Fibonacci sequence are the numbers in the following integer sequence:

$1,;1,;2,;3,;5,;8,;13,;21,;34,;55,;89,;144,; ldots;$

or (often, in modern usage):

$0,;1,;1,;2,;3,;5,;8,;13,;21,;34,;55,;89,;144,; ldots;$ (sequence A000045 in OEIS).
By definition, the first two numbers in the Fibonacci sequence are either 1 and 1, or 0 and 1, depending on the chosen starting point of the sequence, and each subsequent number is the sum of the previous two.

In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation

$F_n = F_{n-1} + F_{n-2},!,$

with seed values

$F_1 = 1,; F_2 = 1$

or

$F_0 = 0,; F_1 = 1.$

## C++ program to convert decimal to binary

Hello all, today we are going to write a C++ program to convert decimal to binary number, let’s first discuss how we can convert a decimal number to binary number and later we will write the program for the same.

## How Program works?

Lets take an example of 11.

Now divide it by 2 and note down the remainder.

• So.             11 / 2 , Remainder  = 1.
• Quotient:     5 / 2 , Remainder  = 1.
• Quotient:     2/2 ,  Remainder  =  0.
• Quotient:      1/2,  Remainder  =   1.
• Now Quotient = 0. Stop.

Binary number is the Remainders in reverse order i.e. Binary of 11 = 1011

### OUTPUT:

Hope you find it easy, reply in comment if you face any problem in executing the same.

## C++ program to find HCF and LCM of two numbers

HCF ( Highest Common Factor): The LCM of 2 numbers is Highest common factor of those numbers. For e.g. we have 20 and 30, so HCF will be 10, as 10 is the highest common factor of 20 as well as 30. You must know how to calculate HCF of numbers.

LCM ( Lowest Common Multiple): LCM is the lowest common Multiple of those numbers. For e.g. LCM of 5, 7 is 35, as 35 is the least number divisible by both the numbers.

### How Code Works:

1. Take 2 numbers as ‘a’ and ‘b’, and find multiplication of them in ‘c’ i.e. c = a * b.
2. Now while ‘a’ is not equals to ‘b’ we find the greater and subtract the lower from greater until both become equal.
3. So finally we will have ‘a’ as our HCF and LCM will be ‘c/a’.

### Dry run the Code:

• Let’s take 4 and 6, i.e. a=4 and b=6.
• Now c=a*b i.e. c=4*6 = 24.
• While 4 is not equals to 6
1. 6>4 i.e. b = 6-4 = 2
2. Now a>b i.e. 4>2 so a = 4-2 =2.
3. While is over now as ‘a’ = ‘b’
• HCF = ‘a’ = 2
• LCM = c / a i.e. 24/2 = 12.

Now let’s see the code. We can also find the HCF and LCM of Three numbers

### C++ Program to find HCF and LCM of two numbers

```# include <iostream>;
using namespace std;

int main()
{
int a,b,c;
cout<< "Enter two nos :"<<endl;
cout<<endl;
cout<< "Enter first no. : ";
cin>>a;
cout<< "Enter sec. no. : ";
cin<<b;
c=a*b;
while(a!=b)
{
if(a>b)
a=a-b;
else
b=b-a;
}
cout<< "HCF = " << a<<endl;
cout<< "LCM = " << c/a<<endl;
return 0;
}```

### OUTPUT:

Please comment in case any errors.