Found 7347 Articles for C++

Endian order and binary files in C++

sudhir sharma
Updated on 22-Jan-2021 12:49:11

461 Views

In the binary file and data management, endianness is the sequence of bytes of a digital data inside the computer memory.In computer memory there are two type of endian order,Big-endian system stores the most significant byte of the data.Small-endian systems store the least significant byte of the data.

Emulating a 2-d array using 1-d array in C++

sudhir sharma
Updated on 22-Jan-2021 12:48:54

234 Views

In this problem, we will understand the conversion of 2-D array to 1-D array. We will see how to store the elements of a 2-D array to a 1-D array.Here, the size of 1-D array is same as the total number of elements in 2-D array which is n*m.In programming there are two ways to store a 2-D array to 1-D array. They are−Row MajorColumn MajorRow Major: In row major, All the elements of a row are stored together then it moves to the next row.If an element of 2-D array of size nXm has an index (i, j) is stored ... Read More

Emirp numbers in C++

sudhir sharma
Updated on 22-Jan-2021 12:48:30

397 Views

Emirp number is a special type of number that is a prime number whose digits when reversed create another prime number (this prime number is different from the original one).Emirp is the reverse of prime. Some prime numbers that are not emirp are palindromic prime and single digit prime numbers. Some Emirp Numbers are 13, 17, 37, 733.Program to print all emirp numbers less than n.Here, we are given a number n, and we need to print all emirp numbers less than or equal to n.Let’s take an example to understand the problem, Input: n = 40Output: 13, 17, 31, 37Solution ApproachTo find all emirp numbers less ... Read More

Elo Rating Algorithm in C++

sudhir sharma
Updated on 22-Jan-2021 12:48:13

479 Views

Elo Rating Algorithm is a rating algorithm used to rank players in competitive games. The ranking of player of the competition is based on ranting which changes based on the performance of the player as follows, For a game between two players of different ratings. Let’s say there are two players competing against each other−Player1                          Player2Rating of player1 is greater than player2.If player1 wins the game some player will be transferred from player1 to player2 and vice versa if player2 wins.But the amount of rating to be transferred for victory ... Read More

Elements to be added so that all elements of a range are present in array in C++

sudhir sharma
Updated on 22-Jan-2021 12:40:32

71 Views

In this problem, we are given an array arr[] consisting of n number. Our task is to create a program to find the number of elements to be added so that all elements of a range are present in array. Problem Description: Here, we need to find the number of elements that are needed to be added to the array to make sure that all elements of a range are present in the array. The range is from smallestElement of array to largestElement of array. Let’s take an example to understand the problem, Input: arr[] = {5, 8, 3, 1, 6, 2}Output: 2Explanation:The range is from ... Read More

Elements of an array that are not divisible by any element of another array in C++

sudhir sharma
Updated on 22-Jan-2021 12:39:53

330 Views

In this problem, we are given two arrays arr1[] and arr2[]. Our task is to create a program to find the elements of an array that are not divisible by any element of another array. Problem Description: Here, we need to find all elements from arr1 that are not divisible by any elements of arr2.Let’s take an example to understand the problem, Input: arr1[] = {17, 15, 5, 12, 8}        arr2[] = {5, 4}Output: 17Explanation −Elements of arr1 and elements dividing them, 17 -> no element can divide it.15 -> 5 divides the element.5 -> 5 divides the element.12 -> 4 ... Read More

Elements greater than the previous and next element in an Array in C++

sudhir sharma
Updated on 22-Jan-2021 12:38:53

940 Views

In this problem, we are given an array arr[] of n positive integers. Our task is to create a program to find the elements greater than the previous and next element in an Array. Code Description: We need to find the elements of the array that satisfy the condition, the element is greater that the element at index 1 less than it and also is greater than the element at index 1 greater than it.Let’s take an example to understand the problem, Input: arr[] = {3, 2, 5, 7, 3, 4, 5}Output: 7Explanation −Element with index one less than the current element, 5.Element with ... Read More

Element equal to the sum of all the remaining elements in C++

sudhir sharma
Updated on 22-Jan-2021 12:35:22

111 Views

In this problem, we are given an array arr[] consisting of n positive values. Our task is to find the element equal to the sum of all the remaining elements of the array.Code Description: We need to find the element whose value is equal to the sum of all elements of the array except that element.Let’s take an example to understand the problem, Input: arr[] = { 5, 4, 17, 1, 7 }Output: 17Explanation −The sum of the rest of the element is (5 + 4 + 1 + 7 ) = 17, which is equal to the remaining element 17.Solution Approach −A simple ... Read More

Editors and Its types in System Programming in C++

sudhir sharma
Updated on 22-Jan-2021 12:35:41

4K+ Views

Editors are basically computer programs that are utilised to edit files on a computer. The provide environment to a programmer to create, edit, update, format a document in any order he/she wants to.In system programming or programming, editors are software or tools that are used to edit the program. These are basically text editors of special type that have integrated functionality to edit code.Some common program editors are notepad++, visual code, sublime. Also there are some edits that provide things used to do more than just editing the code. They are the integrated development environment (IDE) which can help you edit, debug and run ... Read More

Easy way to remember Strassen's Matrix Equation in C++

sudhir sharma
Updated on 22-Jan-2021 12:36:00

462 Views

It is a matrix multiplication algorithm is based on divide and conquer method. It is used to multiply two matrices of the same size, Finding multiplication of two matrices−The strassen’s Algorithm reduces overhead for multiplication by simplifying the multiplication.Here is the multiplication made using the strassen’s Algorithm: M1 = a*(f - h) M2 = (a + b)*h M3 = (c + d)*e M4 = d*(g - e) M5 = (a + d)*(e + h) M6 = (b - d)*(g + h) M7 = (a - c)*(e + f) This can be easily remembered and the algorithm code can be decoded. For this we have a few rules, first remember these ... Read More

Advertisements