- 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 35164 Articles for Programming
647 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
617 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
21K+ 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
63K+ 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
34 Views
The wordwrap() function in PHP wraps a string into new lines when it reaches a specific length.Syntaxwordwrap(str,width,break,cut)Parametersstr − The specified stringwidth − The maximum line width. The default is 75break − The characters to use as break. The default is ""cut − If set to TRUE, the string is always wrapped at or before the specified widthReturnThe wordwrap() function returns the string broken into lines on success, or FALSE on failure.ExampleThe following is an example − Live DemoOutputThe following is the output −Java is a programming language developed by James Gosling in 1994.
18 Views
The vsprint() function returns the formatted string.Syntaxvsprintf(format, argarray)Parametersformat − Specifies the string and how to format the variables in it.The following are the possible format values −%% − Returns a percent sign%b − Binary number%c − The character according to the ASCII value%d − Signed decimal number (negative, zero or positive)%e − Scientific notation using a lowercase (e.g. 1.2e+2)%E − Scientific notation using a uppercase (e.g. 1.2E+2)%u − Unsigned decimal number (equal to or greater than zero)%f − Floating-point number (local settings aware)%F − Floating-point number (not local settings aware)%g − shorter of %e and %f%G − shorter of %E ... Read More