## 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 »

## 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 »

## Program to find largest element in an array

Given an array, find the largest element in it. Example: Input : arr[] = {10, 20, 4} Output : 20 Input : arr[] = {20,… Read More »

## Program to check if a given year is leap year

A year is leap year if the following conditions are satisfied: Year is multiple of 400. Year is multiple of 4 and not multiple of… 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 »

## 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 »

## Virtual Functions and Runtime Polymorphism in C++ | Set 1 (Introduction)

Consider the following simple program as an example of runtime polymorphism. The main thing to note about the program is that the derived class’s function… Read More »

## How to compare two arrays in Java?

Predict the output of following Java program. filter_none edit close play_arrow link brightness_4 code class Test {     public static void main (String[] args)      {         int… Read More »

## Exception Handling in C++

One of the advantages of C++ over C is Exception Handling. Exceptions are run-time anomalies or abnormal conditions that a program encounters during its execution.… Read More »

## Private and final methods in Java

When we use final specifier with a method, the method cannot be overridden in any of the inheriting classes. Methods are made final due to… Read More »

## Abstract Classes in Java

In C++, if a class has at least one pure virtual function, then the class becomes abstract. Unlike C++, in Java, a separate keyword abstract… Read More »