# Category Archives: Mathematical

## 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 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 multiply two matrices

Given two matrices, the task to multiply them. Matrices can either be square or rectangular. Examples: Input : mat1[][] = {{1, 2}, {3, 4}} mat2[][]… Read More »

## Count trailing zeroes in factorial of a number

Given an integer n, write a function that returns count of trailing zeroes in n!. Examples : Input: n = 5 Output: 1 Factorial of… Read More »

## Program for nth Catalan Number

Catalan numbers are a sequence of natural numbers that occurs in many interesting counting problems like following. 1) Count the number of expressions containing n… Read More »

## Print all possible words from phone digits

Before the advent of QWERTY keyboards, texts and numbers were placed on the same key. For example, 2 has “ABC” if we wanted to write… Read More »

## Amazon Interview | Set 69 (For SDE-1)

Online Coding Round: Find if a given string contains duplicates Given a BST, find the maximum N elements of the tree Given a BST, convert… Read More »

## Rearrange an array so that arr[i] becomes arr[arr[i]] with O(1) extra space

Given an array arr[] of size n where every element is in range from 0 to n-1. Rearrange the given array so that arr[i] becomes… Read More »

## Find if two rectangles overlap

Given two rectangles, find if the given two rectangles overlap or not. Note that a rectangle can be represented by two coordinates, top left and… Read More »

## C Program to Swap two Numbers

Given two numbers, write a C program to swap the given numbers. Input : x = 10, y = 20; Output : x = 20,… Read More »

## How to swap two numbers without using a temporary variable?

Given two variables, x and y, swap two variables without using a third variable. Method 1 (Using Arithmetic Operators) The idea is to get sum… Read More »

## Program to find sum of elements in a given array

Given an array of integers, find sum of its elements. Examples : Input : arr[] = {1, 2, 3} Output : 6 1 + 2… Read More »