Found 27759 Articles for Server Side Programming

array_reduce() function in PHP

Samual Sam
Updated on 24-Jun-2020 12:24:54

31 Views

The array_reduce() function returns an array as a string, using a user-defined function.Syntaxarray_reduce(arr, custom_func, initial)Parametersarr − The array. Required.custom_func − The name of the user-defined function. Required.initial − Initial value to be sent to the function. Optional.ReturnThe array_reduce() function returns the resulting value. It returns NULL, if the array is an empty array and initial isn’t passed.ExampleThe following is an example − Live DemoOutputThe following is the output −2 DEMO One DEMO TwoExampleLet us see another example wherein the given array is reduced o the product of all the elements of the array − Live DemoOutputThe following is the output −1250Read More

array_push() function in PHP

karthikeya Boyini
Updated on 23-Dec-2019 07:22:39

94 Views

The array_push() function inserts one or more elements to the end of an array. It returns the new elements pushed into the array.Syntaxarray_push(arr, val1, val2)Parametersarr − The specified arrayval1 − The value to be pushedval2 − The value to be pushedReturnThe array_push() function returns the new elements pushed into the array.ExampleThe following is an example − Live DemoOutputThe following is the output −Array ( [0] => table [1] => chair [2] => pen [3] => pencil [4] => notepad [5] => paperclip )

array_pop() function in PHP

Samual Sam
Updated on 23-Dec-2019 06:56:50

44 Views

The array_pop() function deletes the last element of an array. It returns the value of the last element of the array. If the array is empty, NULL is returned.Syntaxarray_pop(arr)Parametersarr − The specified arrayReturnThe array_pop() function returns the last element of the array. If the array is empty, NULL is returned.The following is an example −Example Live DemoOutputThe following is the output −tablet

atan2() function in C++ STL

Arjun Thakur
Updated on 24-Jun-2020 11:42:59

263 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

acos() function in C++ STL

Chandu yadav
Updated on 24-Jun-2020 11:43:36

1K+ Views

The acos() function returns the inverse cosine of an angle given in radians. It is an inbuilt function in C++ STL.The syntax of the acos() function is given as follows.acos(var)As can be seen from the syntax, the function acos() accepts a parameter var of data type float, double or long double. The value of this parameter should be between -1 and 1. It returns the inverse cosine of var in the range of -pi to pi.A program that demonstrates acos() in C++ is given as follows.Example Live Demo#include #include using namespace std; int main() {    double d = ... Read More

C++ Program to Implement Stack using linked list

George John
Updated on 14-Sep-2023 01:28:41

35K+ Views

A stack is an abstract data structure that contains a collection of elements. Stack implements the LIFO mechanism i.e. the element that is pushed at the end is popped out first. Some of the principle operations in the stack are −Push - This adds a data value to the top of the stack.Pop - This removes the data value on top of the stack.Peek - This returns the top data value of the stack.A program that implements a stack using linked list is given as follows.Example#include using namespace std; struct Node {    int data;    struct Node *next; ... Read More

C++ Program to Implement Stack using array

Ankith Reddy
Updated on 31-Aug-2023 02:13:46

128K+ Views

A stack is an abstract data structure that contains a collection of elements. Stack implements the LIFO mechanism i.e. the element that is pushed at the end is popped out first. Some of the principle operations in the stack are −Push - This adds a data value to the top of the stack.Pop - This removes the data value on top of the stackPeek - This returns the top data value of the stackA program that implements a stack using array is given as follows.Example#include using namespace std; int stack[100], n=100, top=-1; void push(int val) {    if(top>=n-1)   ... Read More

C++ Program to Implement Doubly Linked List

Arjun Thakur
Updated on 05-Oct-2023 01:16:17

30K+ Views

Doubly linked list is a type of data structure that is made up of nodes that are created using self referential structures. Each of these nodes contain three parts, namely the data and the reference to the next list node and the reference to the previous list node.Only the reference to the first list node is required to access the whole linked list. This is known as the head. The last node in the list points to nothing so it stores NULL in that part. Also the doubly linked list can be traversed in both directions as each node points ... Read More

C++ Program to Implement Circular Singly Linked List

Chandu yadav
Updated on 24-Jun-2020 11:53:13

11K+ Views

Circular singly linked list is a type of data structure that is made up of nodes that are created using self referential structures. Each of these nodes contain two parts, namely the data and the reference to the next list node.Only the reference to the first list node is required to access the whole linked list. This is known as the head. The last node in the list points to head or first node of the list. That is the reason this is known as a circular linked list.A program to implement circular singly linked list is given as follows.Example Live ... Read More

C++ Program to Implement Singly Linked List

George John
Updated on 02-Sep-2023 12:10:41

66K+ Views

Singly linked list is a type of data structure that is made up of nodes that are created using self referential structures. Each of these nodes contain two parts, namely the data and the reference to the next list node. Only the reference to the first list node is required to access the whole linked list. This is known as the head. The last node in the list points to nothing so it stores NULL in that part.A program to implement singly linked list is given as follows.Example Live Demo#include using namespace std; struct Node {    int data;   ... Read More

Advertisements