Program to find sum of series 1 + 1/2 + 1/3 + 1/4 + .. + 1/n

If inverse of a sequence follows rule of an A.P i.e, Arithmetic progression, then it is said to be in Harmonic Progression.In general, the terms… Read More »

C Program to print Floyd’s triangle

Floyd’s triangle is a triangle with first natural numbers. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Recommended:… Read More »

Program to print first n Fibonacci Numbers | Set 1

Following is simple program to print first n Fibonacci numbers. Examples : Input : n = 3 Output : 1 1 2 Input : n… Read More »

Program to find area of a circle

Area of a circle can simply be evaluated using following formula. Area = pi * r2 where r is radius of circle Recommended: Please solve… Read More »

Program to find area of a triangle

Finding area using given sides: Examples : Input : a = 5, b = 7, c = 8 Output : Area of a triangle is… Read More »

Program to check if two given matrices are identical

The below program checks if two square matrices of size 4*4 are identical or not.For any two matrix to be equal, number of rows and… Read More »

Recursive program to linearly search an element in a given array

Given an unsorted array and an element x, search x in given array. Write recursive C code for this. If element is not present, return… Read More »

Program to find transpose of a matrix

Transpose of a matrix is obtained by changing rows to columns and columns to rows. In other words, transpose of A[][] is obtained by changing… Read More »

Program for subtraction of matrices

The below program subtracts of two square matrices of size 4*4, we can change N for different dimension. C++ filter_none edit close play_arrow link brightness_4… Read More »

Program for addition of two matrices

The below program adds two square matrices of size 4*4, we can change N for different dimension. Recommended: Please solve it on “PRACTICE” first, before… Read More »

Program for factorial of a number

Factorial of a non-negative integer, is multiplication of all integers smaller than or equal to n. For example factorial of 6 is 6*5*4*3*2*1 which is… Read More »

Program to find LCM of two numbers

LCM (Least Common Multiple) of two numbers is the smallest number which can be divided by both numbers. For example LCM of 15 and 20… Read More »

Program to find GCD or HCF of two numbers

GCD (Greatest Common Divisor) or HCF (Highest Common Factor) of two numbers is the largest number that divides both of them. For example GCD of… Read More »

Program to cyclically rotate an array by one

Given an array, cyclically rotate the array clockwise by one. Examples: Input: arr[] = {1, 2, 3, 4, 5} Output: arr[] = {5, 1, 2,… Read More »

Program for Tower of Hanoi

Tower of Hanoi is a mathematical puzzle where we have three rods and n disks. The objective of the puzzle is to move the entire… Read More »