
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7197 Articles for C++

663 Views
An array in C++ is a data structure used to store multiple values of the same type in a contiguous block of memory. To know that how values shift from one index to the next, a common and practical technique is to compute the absolute difference between each pair of consecutive elements. Absolute Difference The absolute difference is the positive distance between two numbers, regardless of which one is larger. It is computed using the abs() function from the library. Absolute difference between a and b is denoted as |a - b|. For example, |7 - 3| = ... Read More

250 Views
In this article, we will solve a sum array puzzle, where we have an array with n elements. We have to create another array of n elements such that the 'ith' position of the second array will hold the sum of all elements of the first array except the 'ith' element. We have one constraint, we cannot use the subtraction operator in this problem. Example Here is an example of calculating the sum of array elements except for the ith element: Input: arr[] = {5, 6, 7, 8} Output: res[] = ... Read More

287 Views
Here we will see one interesting problem related to array. There is an array with n elements. We have to create another array of n elements. But the i-th position of second array will hold the product of all elements of the first array except the i-th element. And one constraint is that we cannot use the division operator in this problem.If we can use the division, operation, we can easily solve this problem, by getting the product of all elements, then divide i-th element of first array and store it into i-th place of the second array.Here we are ... Read More

185 Views
Here we will see one interesting problem related to array. There is an array with n elements. We have to create another array of n elements. But the i-th position of second array will hold the product of all elements of the first array except the i-th element. And one constraint is that we cannot use the division operator in this problem. We have to solve this problem in-place without using any additional spaces.If we can use the division, operation, we can easily solve this problem, by getting the product of all elements, then divide i-th element of first array ... Read More

258 Views
Here we will see one interesting Boolean matrix problem. One Boolean matrix is given which contains 0’s and 1’s. Our goal is to find where 1 is marked. If the 1 is marked at position mat[i, j], then we will make all entries to 1 of the row i and column j. Let us see an example. If the matrix is like below −1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0Then after modification, it will be −1 1 1 1 1 1 0 1 1 1 0 1 1 1 1 1AlgorithmmatrixUpdate(matrix[R, ... Read More

1K+ Views
A simple calculator allows the user to perform basic math operations like addition, subtraction, multiplication, and division . The user inputs two numbers and selects an operation. For example, if the user enters 4 and 3, then selects the "+" operation, the calculator will perform addition and output the result, 7. Similarly, if the user selects "-", the program will perform subtraction (4 - 3 = 1), and so on. In C++, this can be done using conditional statements and basic math operators. In this article, we will show you how to write a simple calculator program in ... Read More

1K+ Views
Power function is used to calculate the power of the given number.The pow function find the value of a raised to the power b i.e. ab.Syntaxdouble pow(double a , double b)It accepts a double integers as input and output a double integer as output. It pow() function is defined in math.h package.If you pass an integer to the power function, the function converts it into double data type. But there's an issue with this, sometimes this conversion might store this as a lower double. For example, if we pass 3 and is converted as 2.99 then the square is 8.99940001 ... Read More

804 Views
Prufer code uniquely identifies a tree which is given by user as a graph representation with labels from 1 to p. This tree consist p(value is given by user) labels of node. It has sequence of p – 2 values.AlgorithmBegin Declare i, j, ver, edg, minimum, p to the integer datatype. Print “Enter the number of vertexes: ”. Enter the value of ver. Initialize edg = ver-1. Declare EDG[edg][2], DG[ver+1] to the integer datatype. Initialize DG[ver+1] = {0}. Print “This tree has (value of edg) edges for (value of ver) vertexes”. ... Read More

603 Views
It is the program to print prime numbers in a given range.AlgorithmsBegin Declare a user define datatype stl. Declare a vector number to the stl datatype. Declare variable a to the stl datatype. Declare vector Prime_Number to the Boolean datatype. Prime_Number[0] = false. Prime_Number[1] = false. Declare b to the integer datatype. Initialize b = sqrt(a). for (stl pr=2; pr

831 Views
This is the program to find closest pair of points in an array.AlgorithmsFor Distance between Closest pointBegin Declare function Closest_dist_Spoint(poi stp[], int s, double dist, poi &pnt1, poi &pnt2) to the double datatype. Declare Minimum to the double datatype. Initialize Minimum = dist. for (int i = 0; i < s; ++i) for (int j = i+1; j < s && (stp[j].poi2 - stp[i].poi2) < Minimum; ++j) if (Distance(stp[i], stp[j]) < Minimum) then Minimum = Distance(stp[i], stp[j]). ... Read More