Skip to content

Category Archives: C++ Programs

Given a number N and a digit D. Write a program to find how many times the digit D appears in the number N.Examples :  … Read More
bitset::count() is an inbuilt STL in C++ which returns the number of set bits in the binary representation of a number. Syntax: int count() Parameter:… Read More
count_if() function returns the number of elements in a range that satisfy the condition. Syntax:  template <class InputT, class UnaryPredicate> typename iterator_traits <InputT> :: difference_type… Read More
Given an array of N integers, write a program that prints the length of the longest subarray such that adjacent elements of the subarray have… Read More
Suppose there are n towns connected by m bidirectional roads. There are s towns among them with a police station. We want to find out… Read More
The Strassen’s method of matrix multiplication is a typical divide and conquer algorithm. We have discussed Strassen’s Algorithm here. However, let’s get again on what’s… Read More
The tellg() function is used with input streams, and returns the current “get” position of the pointer in the stream. It has no parameters and… Read More
Delete is an operator that is used to destroy array and non-array(pointer) objects which are created by new expression.  Delete can be used by either… Read More
Given a string S consisting of only characters ‘a’ and ‘b’, and an integer N. The string S is added N times to obtain string… Read More
Give a sentence, print different words present in it. Words are separated by space.  Examples:  Input : str = "Geeks for Geeks" Output : Geeks… Read More
Java import*;   class GFG {   public static void main(String[] args) {                   System.out.println("Enter The String : ");         String str = "geeksforgeeks";         StringBuffer sb… Read More
Given an array of n integers, slope of a line i. e., m and the intercept of the line i.e c, Count the number of… Read More
Given an array ‘a[]’ of size n and number of queries q. Each query can be represented by two integers l and r. Your task… Read More
We sometimes come across abnormal crash of C++ programs. Below are some possible reasons which may cause C++ to crash abnormally. Segmentation Fault: It is… Read More
Given an array, find the first element that appears even number of times in the array. It returns the element if exists otherwise returns 0.… Read More

Start Your Coding Journey Now!