# Category Archives: C++ Programs (adsbygoogle = window.adsbygoogle || []).push({});

## Program to count Number of connected components in an undirected graph

Given an undirected graph g, the task is to print the number of connected components in the graph. Examples: Input: Output: 3 There are three… Read More »

## TCS Coding Practice Question | Checking Leap Year

Given a number N, the task is to check if N is a Leap Year or not using Command Line Arguments. Examples: Input: N =… Read More »

## TCS Coding Practice Question | Checking Prime Number

Given a number N, the task is to check if N is a Prime Number or not using Command Line Arguments. Examples: Input: N =… Read More »

## TCS Coding Practice Question | Prime Numbers upto N

Given a number N, the task is to find the Prime Numbers from 1 to N using Command Line Arguments. Examples: Input: N = 7… Read More »

## TCS Coding Practice Question | Sum of Digits of a number

Given a number, the task is to find the Sum of Digits of this number using Command Line Arguments. Examples: Input: num = 687 Output:… Read More »

## Times required by Simple interest for the Principal to become Y times itself

Given that a certain amount of money becomes T1 times itself in N1 years. The task is to find the number of years i.e. N2… Read More »

## Count the number of 1’s and 0’s in a binary array using STL in C++ ?

Given a binary array, the task is to count the number of 1’s and 0’s in this array using STL in C++. Examples: Input: arr[]… Read More »

## Find elements of an Array which are Odd and Even using STL in C++

Given an array, the task is to find elements which are odd and even, using STL in C++ Examples: Input: a[] = {1, 2, 3,… Read More »

## Find elements of an array which are divisible by N using STL in C++

Given an array and an integer N, find elements which are divisible by N, using STL in C++ Examples: Input: a[] = {1, 2, 3,… Read More »

## All reverse permutations of an array using STL in C++

Given an array, the task is to print or display all the reverse permutations of this array using STL in C++. Reverse permutation means, for… Read More »

## Generics in C++

Generics is the idea to allow type (Integer, String, … etc and user-defined types) to be a parameter to methods, classes and interfaces. For example,… Read More »

## Element in a matrix starting from which anti-clockwise traversal ends at the last element

Given a mat[][] of size n X n, the task is to find an element X such that if the anti-clockwise traversal is begun from… Read More »

## Replace the odd positioned elements with their cubes and even positioned elements with their squares

Given an array arr[] of n elements, the task is to replace all the odd positioned elements with their cubes and even positioned elements with… Read More »

## Shuffle an Array using STL in C++

Given an array, the task is to shuffle the whole array and print it. Example Input (1, 2, 3, 4, 5, 6, 7} Output {3,… Read More »

## Maximum sub-tree sum in a Binary Tree such that the sub-tree is also a BST

Given a binary tree, the task is to print the maximum sum of nodes of a sub-tree which is also a Binary Search Tree. Examples:… Read More »