Found 33676 Articles for Programming

C++ Program to Implement Fisher-Yates Algorithm for Array Shuffling

Nishu Kumari
Updated on 30-May-2025 18:02:00

816 Views

Shuffling an array means rearranging its elements in a random order. The Fisher-Yates algorithm creates a shuffle where every possible order is equally likely to happen. In this article, we'll show you how to write a C++ program that uses Fisher-Yates algorithm to shuffle an array. Fisher-Yates Algorithm to Shuffle an Array To shuffle an array, we use the Fisher-Yates algorithm. It works by swapping each element with another randomly selected element from the part of the array that we haven't shuffled yet. Here are the steps we follow: First, we start ... Read More

C++ Program to Find GCD of Two Numbers Using Recursive Euclid Algorithm

Nishu Kumari
Updated on 18-Aug-2025 18:44:02

6K+ Views

The Greatest Common Divisor (GCD) of two numbers is the largest number that divides both of them. In this article we'll show you how to write a C++ program to find the GCD of two numbers using the recursive Euclid's algorithm. For example: Let's say we have two numbers that are 63 and 21. Input: 63 and 21 => 63 = 7 * 3 * 3 => 21 = 7 * 3 So, the GCD of 63 and 21 is 21. Output: 21 Finding GCD Using Recursive Euclid Algorithm The recursive Euclid algorithm helps us find ... Read More

C++ Program to Solve any Linear Equation in One Variable

Nishu Kumari
Updated on 22-May-2025 19:13:53

6K+ 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. Let's understand this with an example: //Example 1 If the input equation is 2X + 4 = -9X + 14, the solution is: => 2X + 9x = 14 - 4 => 11X = 10 => X = 10 / 11 = 1.1 //Example 2 If the input equation is -3X + 5 = 4X - 9 the solution is: => -3X + ... Read More

C++ Program to Implement Queue using Linked List

Chandu yadav
Updated on 25-Jun-2020 09:00:06

29K+ 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

C++ Program to Implement Queue using Array

Aman Kumar
Updated on 28-May-2025 16:41:21

93K+ Views

A queue is a linear 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. Implementation Steps Based on the below implementation. Here are the steps to implement queue using array: Initialize Queue: Create an array queue[100] and set front and rear to -1 to indicate an empty queue. Predefine Input Values: Store input elements in input_values[] for insertion. ... Read More

number_format() function in PHP

Samual Sam
Updated on 26-Dec-2019 07:21:15

324 Views

The number_format() function is used to format a number with grouped thousands.Syntaxnumber_format(num,decimals,decimal_pt,separator)Parametersnum − The number to be formatted.decimals − Specifies how many decimals.decimal_pt − The string to be used for decimal point.separator − Specifies the string to be used for thousands separator.ReturnThe number_format() function returns the formatted number.ExampleThe following is an example − Live DemoOutputThe following is the output −10,000,000ExampleLet us see another example − Live DemoOutputThe following is the output −4,000

nl_langinfo() function in PHP

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

97 Views

The nl_langinfo() function has contained information about language and locale. Note − This function won’t work on Windows. Syntax nl_langinfo(ele) Parameters ele − Specify what element to return. Should be any of the following elements − Time and Calendar − ABDAY_(1-7) - Abbreviated name of the numbered day of the week DAY_(1-7) - Name of the numbered day of the week (DAY_1 = Sunday) ABMON_(1-12) - Abbreviated name of the numbered month of the year MON_(1-12) - Name of the numbered month of the year AM_STR - String for Ante meridian PM_STR - String for Post ... Read More

explode() function in PHP

Samual Sam
Updated on 24-Jun-2020 13:28:14

333 Views

The explode() function is used to split a string by string.Syntaxexplode(delimiter, str, limit)Parametersdelimiter − The boundary stringstr − String to splitlimit − Specifies the number of array elements to return.The following are possible values −Greater than 0 - Returns an array with a maximum of limit element(s)Less than 0 - Returns an array except for the last -limit elements()0 - Returns an array with one elementReturnThe explode() function returns an array of strings.The following is an example −Example Live DemoThe following is the output −OutputArray (    [0] => This    [1] => is    [2] => demo    [3] => ... Read More

convert_cyr_string() function in PHP

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

109 Views

The convert_cyr_string() function is used to convert from one Cyrillic character set to another. The supported Cyrillic character-sets are − k - koi8-r w - windows-1251 i - iso8859-5 a - x-cp866 d - x-cp866 m - x-mac-cyrillic Syntax convert_cyr_string(str, from, to) Parameters str − String to format from − The source Cyrillic character set, as a single character. to − The destination Cyrillic character set, as a single character. Return The convert_cyr_string() function returns the converted string. The following is an example − Example Live Demo ... Read More

timezone_name_get() function in PHP

Samual Sam
Updated on 24-Dec-2019 10:22:52

57 Views

The timezone_name_get() function returns the name of the timezone.Syntaxtimezone_name_get(obj)Parametersobj − A DateTimeZone object.ReturnThe timezone_name_get() function returns array on success or FALSE on failure.ExampleThe following is an example − Live DemoOutputThe following is the output −Europe/Paris

Advertisements