Factorial can be evaluated recursively and its very difficult for large numbers. So here we writing code in recursive way using for loop and while loop. Using For Loop: C++ program for factorial of a number C program for factorial…

Generally factorial of a number of a non-negative integer is the multiplication of all integers smaller than or equal to n. For example, Factorial of 6 is 6*5*4*3*2*1 which is 720. Recursive Solution: Factorial can be calculated by following recursive…

Suppose, to get first and last elements from array- Given an array, find first and last elements of it. In C++, we can use sizeof operator to find number of elements in an array. Output: Generally we shouldn’t passed the sizeof array…

Through string subsequence, Suppose two strings str1 and str2, then find str1 is a subsequence of str2. A subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining…

String palindrome c++, Here, suppose there is a string S and a binary string B, both of length N, then the task is to check if the given string S can be made palindromic by repeatedly swapping characters at any pair of indices consisting of unequal characters in the string B.…

Convert an array into another by, Suppose there are two arrays A[] and B[], both developed of a permutation of first N natural numbers, then the task is to count the minimum number of times the last array element is required to be shifted to any arbitrary position…

Minimize the length of the string by removing suffixes and prefixes of the same characters: Suppose a string S has a length of N developed only characters ‘a’, ‘b’, and ‘c’, then the task is to minimize the length of the given string, by doing the following operations…

Given two strings a and b, form a new string of length l, from these strings by combining the prefix of string a and suffix of string b. How to solve String from prefix and suffix of given two strings: 1. Get first l letters from…

Given a quadratic equation in the form ax2 + bx + c, find roots of it. Examples Of Quadratic Equation: Below is direct formula for finding roots of quadratic equation. Here we discuss about following cases: Here implementation of above formula:…