
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7197 Articles for C++

1K+ Views
Given two strings Str and subStr as input. The goal is to find whether text present in subStr exists in Str as substring or not. The string X is called a substring of Y if whole X is present in Y at least once. We will use a recursive approach to do this.For ExampleInput − Str = “tutorialspoint” subStr=”Point”Output − Given string does not contain substring!Explanation − The string Point is not substring of tutorialspointInput − Str = “globalization” subStr=”global”Output − Given string contains substring!Explanation − The string global is substring of globalizationApproach used in the below program is as followsIn this approach we check ... Read More

1K+ Views
Insertion Sort is one of the sorting algorithms used to sort data by inserting elements like a deck of cards. All the elements are arranged from left to right then considering the first one as already sorted, insert rest to the sorted list on the left. Each element is compared with each element in the left list until it is inserted at its correct position.Insertion Sort Algorithmint arr[5]= { 5, 4, 2, 1, 3 };int i, j ;Traverse from index j=i+1 to jarr[i+1], swap those elements.Set temp=arr[i], arr[i]=arr[i+1] and arr[i+1]=temp.Now decrement length by 1 as the previous loop placed the ... Read More

6K+ Views
We are given a string Str as input. The goal is to find if the input string is a palindrome word or not using a recursive function. Palindrome strings are those strings that when read from front or end form the same word. The strings of length 0 are considered as palindromes. Reversing the palindromes character wise forms, the same string as the original.Examples of palindromes are:- madam, abcba, malayalam etcExamplesInput − Str = “malayalam”Output − Input string is palindrome.Explanation −Str[ 0 to 8 ] = malayalamReverse Str [ 8 to 0 ] = malayalamBoth strings are same.Input − Str = “tutorial”Output − Input string ... Read More

392 Views
We are given a string type variable, let's say, str which will be used to store the source code then calculate the size of the string and pass it to the function. The task is to rearrange the given source code and then print the result.Let us see various input output scenarios for this −Input − string str ="#include using namespace std; int main()" "{ int sum, first, second; sum = first + second; printf(\"%d\", c);" " return 0;}"Output −#include using namespace std; int main(){ int sum, first, second; sum = first + second; printf("%d", ... Read More

307 Views
We are given with a string ‘str’ of any given length. The task is to rearrange the characters in such a manner that there will be maximum substrings that will be a palindrome string without adding or removing a character from the given input string. Palindrome string is the one in which the characters are arranged in such a manner that they pronounce the same from start and last.Let us see various input output scenarios for this −Input − string str = "itnin"Output − Rearrangement of the string to maximize the number of palindromic substrings is: iinnt.Explanation − We are given a string ... Read More

372 Views
We are given an integer type number, let's say, number. The task is to rearrange number digit’s in such a manner that a number formed after rearrangement is also divisible by the given number i.e. ’number’.Let us see various input output scenarios for this −Input − int number = 100035Output − Rearrangement of a number which is also divisible by it is: 300105Explanation − we are given an integer number as ‘number’ i.e. 100035. Now, the task is to rearrange these given digits in such a manner that the formed number will be divisible by 100035. So, after rearranging the digits we got ... Read More

1K+ Views
We are given with a string ‘str’ of any given length. The task is to rearrange the characters in such a manner that the output will be a palindrome string without adding or removing a character from the given input string. Palindrome string is the one in which the characters are arranged in such a manner that they pronounce the same from start and last.Let us see various input output scenarios for this −Input − string str = "itnin"Output − Rearrangement of characters to form palindrome if possible is: nitinExplanation − We are given a string type variable let’s say, str. Now we ... Read More

1K+ Views
We are given an integer type array containing both positive and negative numbers, let's say, arr[] of any given size. The task is to rearrange an array in such a manner that when the lowest element in an array is odd then elements of an array will be rearranged in odd first and even second manner. When the lowest element in an array is even then elements of an array will be rearranged in even first and odd second manner and if the number of even/odd elements is more than the number of odd/even elements then it will place the ... Read More

159 Views
We are given integer variables, let's say, N and K. The task is to firstly calculate the permutation of N and then rearrange the permutation in such a manner that it will be K distance from every element.Let us see various input output scenarios for this −Input − int n = 20, int k = 2Output − Rearrangement of first N numbers to make them at K distance is: 3 4 1 2 7 8 5 6 11 12 9 10 15 16 13 14 19 20 17 18.Explanation − we are given integer variables ‘N’ i.e. 20 and ‘K’ i.e. 2. Now ... Read More

364 Views
We are given an integer type array containing both positive and negative numbers, let's say, arr[] of any given size. The task is to rearrange an array in such a manner that all the elements of an array are sorted using the inbuilt sort function of C++ STL as well as using recursive technique of coding and printing the result.Let us see various input output scenarios for this −Input − int arr[] = {4, 2, -1, -1, 6, -3, 0}Output − Rearrangement of positive and negative numbers with constant extra space is: -3 -1 -1 0 6 2 4.Explanation − we are given ... Read More