Skip to content

Category Archives: C++ Programs

Given a number num as a string and a number N. The task is to write a program which converts the given number num to… Read More
Given a string of digits and characters. Write a program to find the number with the maximum number of digits in a string. Note: The number… Read More
Given two numbers M and N. The task is to print the number which has the maximum number of distinct prime factors of numbers in… Read More
atol() The atol() function converts a C-style string (array of characters), passed as an argument to atol() function, to a long integer. It converts the… Read More
std::stol(): This function converts the string, provided as an argument in the function call, to long int. It parses str interpreting its content as an… Read More
array::crbegin() is a built-in function in C++ STL which returns a constant reverse iterator pointing to the last element in the container. Syntax: array_name.crbegin() Parameters:… Read More
Given two integers say a and b. Find the quotient after dividing a by b without using multiplication, division and mod operator.Examples:  Input: a =… Read More
bitset::test() is an inbuilt function in C++ STL which tests whether the bit at a given index is set or not.  Syntax: bitset_name.test(index) Parameters: The… Read More
set::rbegin() is a built-in function in C++ STL which returns a reverse iterator pointing to the last element in the container. Syntax: reverse_iterator set_name.rbegin() Parameters:… Read More
Given a binary string and a number m, the task is to check if the string has m consecutive 1’s or 0’s. Examples:  Input :… Read More
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