Sunidhi Bansal

Sunidhi Bansal

809 Articles Published

Articles by Sunidhi Bansal

Page 56 of 81

Count n digit numbers not having a particular digit in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 316 Views

We are given a number let’s say, num and a total number of digits stored in an integer type variable let’s say, digi and the task is to calculate the count of those n digits numbers that can be formed where the given digit is not there.Input − n = 2, digit = 2Output − count is 153Explanation − count of all two digit numbers(n) not having digit 2 is 153 as 10, 11, 13, 14, 15, 16, 17, 18, 19, 30, 31, 33, 34, ......., etc.Input − n = 3, digit = 3Output − count is 2187Explanation − count ...

Read More

Count frequency of k in a matrix of size n where matrix(i, j) = i+j in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 355 Views

We are given a matrix of integer values and the task is to calculate the count of the frequency of a given integer variable let’s say, k in the matrix. The size of a matrix can depend upon the size the user wants and in the below program we are taking it to be 4X4. Matrix will be formed on the given condition i.e matrix(i, j) will be i+j. The index value of the first data in a matrix will be 0 and 0 i.e. matrix[0][0] = 0.Input − int size = 4, k = 4Output − count of 4 ...

Read More

Count Number of animals in a zoo from given number of head and legs in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 1K+ Views

We are given a total number of heads and legs in a zoo and the task is to calculate the total number of animals there in the zoo with the given data. In the below program we are considering animals to be deer and peacocks.Input −heads = 60 legs = 200Output −Count of deers are: 40 Count of peacocks are: 20Explanation −let total number of deers to be : x Let total number of peacocks to be : y As head can be only one so first equation will be : x + y = 60 And deers have 4 ...

Read More

Count natural numbers whose all permutation are greater than that number in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 556 Views

We are given a natural number let’s say, num and the task is to calculate the count of all those natural numbers whose all permutations are greater than that number.We are working with the following conditions −The data should be natural numbers onlyAll the possible permutations or arrangement of a natural number should be equal or greater than the given number. For example, the number is 20Consider all the numbers till 20 starting from 1 i.e. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20Now check those numbers whose arrangement or permutation is equaled or greater than the given number i.e. 20. Numbers are 1, 2, 3, 4, 5, 6, 7, 8, 9, 11=11, 12

Read More

ratio_equal() in C++ with example

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 324 Views

In this article, we will be discussing the working, syntax, and examples of ratio_equal() function in C++ STL.What is ratio_equal template?ratio_equal template is inbuilt in C++ STL, which is defined in header file. ratio_equal is used to compare the two ratios. This template accepts two parameters and checks whether the given ratios are equal or not. Like we have two ratios, 1/2 and 3/6 which are equal when we simplify them but the numbers are not equal so C++ has an inbuilt template to check whether the two ratios are equal or not and return true if they are ...

Read More

ilogb() function in C++ STL

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 160 Views

In this article, we will be discussing the working, syntax, and examples of ilogb() function in C++.What is ilogb()?ilogb() function is an inbuilt function in C++ STL, which is defined in iostream> using namespace std; int main(){    int output, var = 2;    output = ilogb(var);    cout

Read More

logical_and in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 181 Views

In this article, we will be discussing the working, syntax, and examples of logical_and function object class in C++.What is logical_and?logical_and binary function is an inbuilt binary function object class in C++, which is defined in a header file. logical_and is a binary function used to give the result of logical “and” operation between two arguments.Logical AND is the binary operation that returns true only and only if both the binary values are true.Syntax of logical_andTemplate struct logical_and : binary_function {    T operator() (const T& a, const T& b) const {return a&b&; } };Template parametersThe function accepts the ...

Read More

Modulus function in C++ STL

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 4K+ Views

In this article, we will be discussing the working, syntax, and examples of modulus functions in C++.What is modulus function C++?modulus function object class in C++, which is defined in header file. modulus function is a binary function object class used to get the result of the modulus operation of the two arguments. This function works the same as the operator ‘% ‘.Syntax of modulus functionTemplate struct modulus : binary_function {    T operator() (const T& a, const T& b) const {return a%b; } };Template parametersThe function accepts the following parameter(s) −T − This is the type of the ...

Read More

Raw string literal in C++ program

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 686 Views

In this article, we will be discussing the raw string literal in C++, its meaning, and examples.There are escape characters in C++ like “” or “\t”. When we try to print the escape characters, it will not display on the output. To show the escape characters on the output screen we use a raw string literal by using R”(String with escape characters)”. After using R in the front of the string the escape character will be displayed on the output.ExampleLet’s understand this with the help of an example#include using namespace std; int main(){    string str = "tutorialspoint" ; ...

Read More

map rbegin() function in C++ STL

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 239 Views

In this article we will be discussing the working, syntax and examples of map::rbegin() function in C++ STL.What is a Map in C++ STL?Maps are the associative container, which facilitates to store the elements formed by a combination of key value and mapped value in a specific order. In a map container the data is internally always sorted with the help of its associated keys. The values in the map container are accessed by its unique keys.What is a map::rbegin()?map::rbegin() function is an inbuilt function in C++ STL, which is defined in  header file. rbegin() implies reverse begin function, this ...

Read More
Showing 551–560 of 809 articles
« Prev 1 54 55 56 57 58 81 Next »
Advertisements