- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 7346 Articles for C++
1K+ Views
In a computer system, the binary number is expressed in the binary numeral system while the octal number is in the octal numeral system. The binary number is in base 2 while the octal number is in base 8.Examples of binary numbers and their corresponding octal numbers are as follows −Binary NumberOctal Number011011500101510110260101012A program that converts the octal numbers into binary is given as follows −Example Live Demo#include #include using namespace std; int OctalToBinary(int octalNum) { int decimalNum = 0, binaryNum = 0, count = 0; while(octalNum != 0) { decimalNum += (octalNum%10) ... Read More
705 Views
In a computer system, the binary number is expressed in the binary numeral system while the octal number is in the octal numeral system. The binary number is in base 2 while the octal number is in base 8.Examples of binary numbers and their corresponding octal numbers are as follows −Binary NumberOctal Number010101200111711001311000020A program that converts the binary numbers into octal and the octal numbers into binary is given as follows −Example Live Demo#include #include using namespace std; int BinarytoOctal(int binaryNum) { int octalNum = 0, decimalNum = 0, count = 0; while(binaryNum != 0) { ... Read More
4K+ Views
The LU decomposition of a matrix produces a matrix as a product of its lower triangular matrix and upper triangular matrix. The LU in LU Decomposition of a matrix stands for Lower Upper.An example of LU Decomposition of a matrix is given below −Given matrix is: 1 1 0 2 1 3 3 1 1 The L matrix is: 1 0 0 2 -1 0 3 -2 -5 The U matrix is: 1 1 0 0 1 -3 0 0 1A program that performs LU Decomposition of a matrix is given below −Example#include using namespace std; void LUdecomposition(float a[10][10], float ... Read More
650 Views
Fisher-Yates algorithm generates a random permutation of the array elements i.e. it randomly shuffles all the elements of an array. All the permutations for the array are equally likely as the Fisher-Yates algorithm is unbiased.A program to implement the Fisher-Yates Algorithm for array shuffling in C++ is given as follows −Example#include #include using namespace std; int main() { int n; cout
5K+ Views
The Greatest Common Divisor (GCD) of two numbers is the largest number that divides both of them.For example: Let’s say we have two numbers that are 63 and 21.63 = 7 * 3 * 3 21 = 7 * 3So, the GCD of 63 and 21 is 21.The recursive Euclid’s algorithm computes the GCD by using a pair of positive integers a and b and returning b and a%b till b is zero.A program to find the GCD of two numbers using recursive Euclid’s algorithm is given as follows −Example Live Demo#include using namespace std; int gcd(int a, int b) ... Read More
5K+ Views
Complex numbers are numbers that are expressed as a+bi where i is an imaginary number and a and b are real numbers. Some examples on complex numbers are −2+3i 5+9i 4+2iA program to perform complex number multiplication is as follows −Example Live Demo#include using namespace std; int main(){ int x1, y1, x2, y2, x3, y3; cout y1; cout y2; x3 = x1 * x2 - y1 * y2; y3 = x1 * y2 + y1 * x2; cout
5K+ Views
Any linear equation in one variable has the form aX + b = cX + d. Here the value of X is to be found, when the values of a, b, c, d are given.A program to solve a linear equation in one variable is as follows −Example Live Demo#include using namespace std; int main() { float a, b, c, d, X; coutd; cout
23K+ Views
A queue is an abstract data structure that contains a collection of elements. Queue implements the FIFO mechanism i.e the element that is inserted first is also deleted first. In other words, the least recently added element is removed first in a queue.A program that implements the queue using linked list is given as follows −Example#include using namespace std; struct node { int data; struct node *next; }; struct node* front = NULL; struct node* rear = NULL; struct node* temp; void Insert() { int val; coutdata = val; front = rear; ... Read More
70K+ Views
A queue is an abstract data structure that contains a collection of elements. Queue implements the FIFO mechanism i.e., the element that is inserted first is also deleted first. In other words, the least recently added element is removed first in a queue.A program that implements the queue using an array is given as follows −Example#include using namespace std; int queue[100], n = 100, front = - 1, rear = - 1; void Insert() { int val; if (rear == n - 1) cout
272 Views
The atan2() function returns the tangent inverse of the coordinate in terms of y and x. Here y and x are the values of the y and x coordinates respectively. It is an inbuilt function in C++ STL.The syntax of the atan2() function is given as follows.atan2(dataType var1, dataType var2)As can be seen from the syntax, the function atan2() accepts two parameters var1 and var2 of data type float, double or long double that are y and x point respectively.The value returned by atan2() is in the range of -pi to pi and is the angle between the (x, y) ... Read More