## Triangle of Numbers Program in C Programming

In C Programming Language we can make many type of shape using numbers and other characters. Here I will show how we can create triangle with number. Please see the below program. Comment here for any questions.

We can create various triangle pattern using C Program as follow:

## Triangle C Program 4:

#### Output of Program:

Please comment here if you have any questions

## Palindrome Numbers Program in C Language

Check whether a number is Palindrome number or not in C Programming Language: A palindrome number is a number of which reverse is same.

For example, Some palindrome numbers examples are 121, 212, 12321, -454. To check whether a number is palindrome or not first we reverse it and then compare the number obtained with the original, if both are same then number is palindrome otherwise not. C program for palindrome number is given below.

## Algorithm Palindrome number

1. Get the number from command prompt.
2. Reverse the number.
3. Compare it with the given number entered from  Command prompt.
4. If both the numbers are same then print the number is palindrome
5. otherswise print number is not palindrome.

## Palindrome number program in C Programming

Output of Program:

Comment here is you ave any queries.

## Find HCF and LCM in C Programming

C program to find HCF (Highest Common Factor) and LCM( Least Common Multiple): Today I will write a program on how to find HCF and LCM of two integers. HCF is also known as Greatest Common Divisor(GCD) or Greatest Common Factor(GCF).

Here there are three methods to find HCF and LCM in C Programming as follow:

1. Find HCF and LCM using Loop
2. Find HCF and LCM using Recursion
3. Find HCF and LCM using Function

## Find HCF and LCM in C Programming using Loop

Output of C Program:

## Find HCF and LCM in C Programming using Function

Please comment if this code is useful to you or having any queries.

## Factorial Program in C Programming

Factorial program in C Programming Language: C Program code to find and print factorial of a number.

Factorial can be achieved by three methods as follow:

1. Factorial Program using loop,
2. Program using a function to find factorial and
3. Factorial Program using recursion.

Factorial is represented using ‘!’, so five factorial will be written as (5!), n factorial as (n!). Also n! = n*(n-1)*(n-2)*(n-3)…3.2.1 and zero factorial is defined as one i.e. 0! = 1.

## Factorial program in C Programming using ‘for’ loop

Here we find factorial using ‘for’ loop.

Output:

## Factorial program in C Programming using function

Here we find factorial using function.

## Factorial program in C Programming using recursion

Here we find factorial using Recursion.

Recursion is a technique in which a function calls itself, for example in above code factorial function is calling itself. To solve a problem using recursion you must first express its solution in recursive form.

Please comment if this post is useful to you or have any queries.

## Add, Subtract, Multiply and Division in C Programming Language

Write a program in C Programming to perform basic arithmetic operation like addition, subtraction, multiplication and division. C Programming Language comes with arithmetic operators. Operator we will use in the C Program are:

• ‘+’ Addition
• ‘-‘ Subtraction
• ‘*’ Multiplication
• ‘/’ Division

This operation can be performed on Integer, Float or Double Number. These are Data Types.

Output:

In c language when we divide two integers we get integer result for example 5/2 evaluates to 2. As a general rule integer/integer = integer and float/integer = float or integer/float = float. So we convert denominator to float in our program, you may also write float in numerator. This explicit conversion is known as typecasting.

## Check Odd or Even Number using C Programming Language

Today I will show How can we check a number is odd or even in C Programming Language. We also use different method to identify even and odd numbers.

As we all know if we divide any number by 2 and the remainder is 0 (zero), then that number is Even, Otherwise its odd. We will use same logic here in C Programming. In C Programming we can get remainder by % (Modulus) operator.

For example of modulus operator, 3%2 gives 1 as remainder. Even numbers are in form of (2*x) and Odd numbers are in form of ((2*x)+1). Here ‘x’ is integer number.

## Program 1: Check whether number is even or odd using modulus operator

We can also check the whether the number is even or odd using bitwise operator & (AND).

For example, Binary of 9 is 1001. When we perform 9 & 1, The result will be 1 and you may observe that the least significant bit of every odd number is 1, so ( odd_number & 1 ) will be always one and also ( even_number & 1 ) is zero.

## Program 3: Check whether number is even or odd using Conditional Operator (Without using ‘if’ Conditional Operator)

In C Programming Language when we divide two integers we get an integer result.

For example the result of 7/3 will be 2. We can take advantage of this and can use it to find whether the number is odd or even. Consider an integer ‘n’ we can first divide by 2 and then multiply it by 2 if the result is the original number then the number is even otherwise the number is odd. For example 11/2 = 5, 5*2 = 10 (which is not equal to eleven), now consider 12/2 = 6 and 6 *2 = 12 ( same as original number). These are some logic which may help you in finding if a number is odd or not.