Found 26504 Articles for Server Side Programming

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

Sunidhi Bansal
Updated on 06-Jun-2020 12:04:31

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 frequency of k in a matrix of size n where matrix(i, j) = i+j in C++

Sunidhi Bansal
Updated on 06-Jun-2020 12:00:30

293 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 n digit numbers not having a particular digit in C++

Sunidhi Bansal
Updated on 06-Jun-2020 11:56:53

275 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 digits in given number N which divide N in C++

Sunidhi Bansal
Updated on 06-Jun-2020 11:53:47

2K+ Views

We are given a number let’s say, N and the task is to find the count of those digits in a number that divides the number N.Points to be rememberIf the digit is 0 then it should be ignored which means count will not be increased for 0.If a digit is appearing twice and it divides the number, then the count will depend upon the digit occurrence. For example, we are given a number 2240 and in this number every digit except the 0 will divide the number and 2 is occurring twice then the count will be 2 for ... Read More

Count n digit numbers divisible by given number in C++

Sunidhi Bansal
Updated on 06-Jun-2020 11:51:27

412 Views

We are given the two elements let’s say, d and num, the task is to find the d digit numbers which are divisible by num.In simple words let us suppose we have given an input 2 in d, so we will first find all the 2-digit numbers i.e. from 10-99 and then find all the numbers which are divisible by num.Let us understand more of this with the help of examples −Input − digit = 2, num= 12Output − Count of n digit numbers divisible by given number: 8Explanation − The 2-digit numbers divisible by 12 are 12, 24, 36, ... Read More

Count entries equal to x in a special matrix in C++

Sunidhi Bansal
Updated on 06-Jun-2020 11:49:25

366 Views

Given a square matrix, mat[][] let the elements of the matrix me mat[i][j] = i*j, the task is to count the number of elements in the matrix is equal to x.Matrix is like a 2d array in which numbers or elements are represented as rows and columns.So, let's understand the solution of the problem with the help of examples −Input −matrix[row][col] = {    {1, 2, 3},    {3, 4, 3},    {3, 4, 5}}; x = 3Output −Count of entries equal to x in a special matrix: 4Input −matrix[row][col] = {    {10, 20, 30},    {30, 40, 30}, ... Read More

Maximum area of rectangle possible with given perimeter in C++

Sunidhi Bansal
Updated on 06-Jun-2020 11:44:04

395 Views

Given a perimeter of a rectangle, the task is to find the maximum area of the rectangle with that given perimeter.A rectangle is a type of parallelogram whose opposite sides are equal and parallel.The perimeter of a rectangle is the sum of all sides of a rectangle; we can also say perimeter is the total distance of the outside of the rectangle.The formula to find the perimeter of a rectangle is − Length + Breadth + Length + Breadth or 2(Length + Breadth)Whereas the area of a rectangle is the size of the rectangular object. The formula for finding the ... Read More

Containers in Bootstrap with examples(3)

Sunidhi Bansal
Updated on 06-Jun-2020 11:37:27

446 Views

As the name suggests, a container is used to hold or bind something likewise containers in bootstrap are used for storing or binding the content over a viewport. Containers add padding to the content by providing it margin from all the four sides of a viewport and it can also be altered depending upon the needs. Containers can also be nested inside one another.Now, let us understand each of the class in detailcontainerIn bootstrap, the .container class creates a responsive container with a fixed width in a viewport.It sets the max-width of a container depending upon the size of a ... Read More

set vs unordered_set in C++ STL(3)

Sunidhi Bansal
Updated on 06-Jun-2020 11:32:02

1K+ Views

In this article, let us understand what is set and unordered_set in C++ STL and thereby gain knowledge of difference between them.What is set?A set is an Associative container which contains a sorted set of unique objects of type Key. Each element may occur only once, so duplicates are not allowed. A user can create a set by inserting elements in any order and the set will return a sorted data to the user which means set contains definition for sorting the data which is abstracted from the user.The main reasons when set can be used are −When sorted data ... Read More

Count minimum frequency elements in a linked list in C++

Sunidhi Bansal
Updated on 06-Jun-2020 11:28:07

399 Views

Given the task is to count the minimum frequency elements in a given linked list which is having duplicate elements.A linked list is a data structure in which the data is stored in the serial order, like a list each element is linked to the next element.The frequency of an element in a linked list refers to the number of times an element is occurring in the linked list. According to the problem we have to count the minimum frequency in a linked list.Let us suppose we have a linked list, 1, 1, 3, 1, 3, 4, 6; where the ... Read More

Advertisements