In this tutorial, we will be discussing a program to find the number of possible positions that can be reached by Modified Knight.For this we will be provided with a 8*8 chessboard. Our task is to find the number of positions Modified Knight can capture with the given number of steps.Example#include using namespace std; //finding the positions void findSteps(int current_row, int current_column, int curr, int board_size, int steps, int* visited){ //bound checking if (current_row >= board_size || current_row < 0 || current_column >= board_size || current_column < 0 || curr > ... Read More
There are several alternatives for compiling C++ on windows. Let's look at 2 of them:GCCTo install GCC on Windows you need to install MinGW. To install MinGW, go to the MinGW homepage, www.mingw.org, and follow the link to the MinGW download page. Download the latest version of the MinGW installation program which should be named MinGW-.exe.While installing MinGW, at a minimum, you must install gcc-core, gcc-g++, Binutils, and the MinGW runtime, but you may wish to install more.Add the bin subdirectory of your MinGW installation to your PATH environment variable so that you can specify these tools on the command ... Read More
In this tutorial, we will be discussing a program to find the number of possible paths from top left to bottom right of a mXn matrix.For this we will be provided with a mXn matrix. Our task is to find all the possible paths from top left to bottom right of the given matrix.Example#include using namespace std; //returning count of possible paths int count_paths(int m, int n){ if (m == 1 || n == 1) return 1; return count_paths(m - 1, n) + count_paths(m, n - 1); } int main(){ cout
In this tutorial, we will be discussing a program to find the number of paths between two vertices.For this we will be provided with a directed graph. Our task is to find the number of paths possible between two given vertices.Example#include using namespace std; //constructing a directed graph class Graph{ int V; list *adj; void countPathsUtil(int, int, bool [], int &); public: //constructor Graph(int V); void addEdge(int u, int v); int countPaths(int s, int d); }; Graph::Graph(int V){ this->V = V; adj ... Read More
In this tutorial, we will be discussing a program to find the number of possible N digit numbers that satisfy the given condition.For this we will be provided with an integer. Our task is to check which one of number having N digits followNumber + Reverse(Number) = 10N -1Example#include using namespace std; //returning the count of numbers string count_num(int N){ if (N % 2 == 1) return 0; string result = "9"; for (int i = 1; i
In this tutorial, we will be discussing a program to find the number of possible groups of size 2 or 3 that have sum as multiple of 3.In this tutorial, we will be discussing a program to find the number of possible groups of size 2 or 3 that have sum as multiple of 3.Example#include using namespace std; //returning count of pairs of //2 or 3 int count_groups(int arr[], int n){ int c[3] = {0}, i; int res = 0; for (i=0; i>1); res += c[1] * c[2]; res += (c[0] * (c[0]-1) * (c[0]-2))/6; ... Read More
In this tutorial, we will be discussing a program to find the number of all perfect divisors of a number.For this we will be provided with a number. Our task is to count all the perfect divisors of that given number.Example#include using namespace std; //checking perfect square bool if_psquare(int n){ int sq = (int) sqrt(n); return (n == sq * sq); } //returning count of perfect divisors int count_pdivisors(int n){ int count = 0; for (int i=1; i*i
In this tutorial, we will be discussing a program to find the number of all palindromic subsequences in a given string.For this we will be provided with a string. Our task is to find the number of palindromic subsequences that can be made in that given string.Example#include #include using namespace std; //returning total palindromic sequence int count_palin(string str){ int N = str.length(); //creating a 2D array int cps[N+1][N+1]; memset(cps, 0 ,sizeof(cps)); for (int i=0; i
In this tutorial, we will be discussing a program to find the number of palindromes which are squares of a palindrome.For this we will be provided with two values L and R. Our task is to find the number of super palindromes in the given range. A super palindrome is the one in which the number and its square both are palindromes.Example#include using namespace std; //checking if the number is a palindrome bool if_palin(int x){ int ans = 0; int temp = x; while (temp > 0){ ans = 10 * ans + ... Read More
Following are some of the differences between C and C++.When compared to C++, C is a subset of C++. All valid C programs are valid C++ programs.C is a structural or procedural programming language, while C++ is an object oriented programming language.In C, Functions are the fundamental building blocks, while in C++, Objects are the fundamental building blocks.C doesn't have variable references, while C++ has variable references.C uses malloc and free for memory allocation while C++ uses new and delete for memory allocation.C does not provide direct support for error handling, while C++ supports exception handling that helps in error ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP