Server Side Programming Articles - Page 1840 of 2650

Menu Driven C++ Program for a Simple Calculator

Ayush Gupta
Updated on 06-Apr-2020 14:15:19

1K+ Views

In this tutorial, we will be discussing a program to create a menu driven program for a simple calculator.This program will give user the ability to choose among the following mathematical operations − addition, subtraction, multiplication, division, HCF and LCM.Example Live Demo#include using namespace std; //displaying the menu void menu(){    cout

Multiset in C++ Standard Template Library (STL)

Ayush Gupta
Updated on 06-Apr-2020 14:10:13

233 Views

In this tutorial, we will be discussing a program to understand Multiset in C++ STL (Standard Template Library).Multiset are associative containers much similar to sets. The one difference multiset holds is they can even contain duplicate values.Example Live Demo#include #include #include using namespace std; int main(){    multiset gquiz1;    //inserting values    gquiz1.insert(40);    gquiz1.insert(30);    gquiz1.insert(60);    gquiz1.insert(20);    gquiz1.insert(50);    gquiz1.insert(50);    gquiz1.insert(10);    multiset :: iterator itr;    cout

multiset lower_bound() in C++ STL with Examples

Ayush Gupta
Updated on 06-Apr-2020 14:05:36

366 Views

In this tutorial, we will be discussing a program to understand multiset lower_bound() in C++ STL.The function lower_bound() returns the first existence of the element in the container equivalent to the provided parameter, else it returns the element immediately bigger than that.Example Live Demo#include using namespace std; int main(){    multiset s;    s.insert(1);    s.insert(2);    s.insert(2);    s.insert(1);    s.insert(4);    cout

multiset upper_bound() in C++ STL with Examples

Ayush Gupta
Updated on 06-Apr-2020 14:00:38

362 Views

In this tutorial, we will be discussing a program to understand multiset upper_bound() in C++ STL.The function upper_bound() returns the pointer to an element which is bigger than the one provided as a parameter, else it returns the pointer to the last element in the container.Example Live Demo#include using namespace std; int main(){    multiset s;    s.insert(1);    s.insert(3);    s.insert(3);    s.insert(5);    s.insert(4);    cout

negative_binomial_distribution in C++ with Examples

Ayush Gupta
Updated on 06-Apr-2020 13:58:33

196 Views

In this tutorial, we will be discussing a program to understand negative_binomial_distribution in C++.This function follows the negative Binomial discrete distribution and produces integers according to this random distribution.Example Live Demo#include using namespace std; int main() {    //setting number of experiments    const int exps = 10000;    const int numberstars = 100;    default_random_engine generator;    negative_binomial_distribution distribution(4, 0.5);    int p[10] = {};    for (int i = 0; i < exps; ++i) {       int counting = distribution(generator);       if (counting < 10)          ++p[counting];    }    cout

multiset max_size() in C++ STL with Examples

Ayush Gupta
Updated on 06-Apr-2020 13:55:35

151 Views

In this tutorial, we will be discussing a program to understand multiset max_size() in C++ STL.The function max_size() returns the maximum number of elements a given container can hold.Example Live Demo#include using namespace std; int main(){    multiset s;    s.insert(10);    s.insert(13);    s.insert(13);    s.insert(25);    s.insert(24);    cout

multiset size() in C++ STL with Examples

Ayush Gupta
Updated on 06-Apr-2020 13:53:28

136 Views

In this tutorial, we will be discussing a program to understand multiset size() in C++ STL.The function size() returns the number of elements present into a given container.Example Live Demo#include using namespace std; int main(){    multiset s;    s.insert(10);    s.insert(13);    cout

order_of_key() in C++

Ayush Gupta
Updated on 06-Apr-2020 13:51:29

841 Views

In this tutorial, we will be discussing a program to understand order_of_key() in C++.The function order_of_key() takes in a key and returns the number of elements which are less than the key provided as parameter in an ordered set.Example Live Demo#include using namespace std; #include #include #include #include using namespace __gnu_pbds; using namespace std; //initializing ordered set typedef tree    ordered_set; int main(){    ordered_set mySet;    mySet.insert(5);    mySet.insert(2);    mySet.insert(6);    mySet.insert(4);       cout

Convert all types of smart quotes with PHP

AmitDiwan
Updated on 06-Apr-2020 09:26:09

836 Views

The below lines of code can be used, wherein UTF-8 input is expected.$chr_map = array(    // Windows codepage 1252    "\xC2\x82" => "'", // U+0082⇒U+201A single low-9 quotation mark    "\xC2\x84" => '"', // U+0084⇒U+201E double low-9 quotation mark    "\xC2\x8B" => "'", // U+008B⇒U+2039 single left-pointing angle quotation mark    "\xC2\x91" => "'", // U+0091⇒U+2018 left single quotation mark    "\xC2\x92" => "'", // U+0092⇒U+2019 right single quotation mark    "\xC2\x93" => '"', // U+0093⇒U+201C left double quotation mark    "\xC2\x94" => '"', // U+0094⇒U+201D right double quotation mark    "\xC2\x9B" => "'", // U+009B⇒U+203A single right-pointing angle ... Read More

How do you pass objects by reference in PHP 5?

AmitDiwan
Updated on 06-Apr-2020 09:19:56

398 Views

A PHP reference is an alias, that allows two different variables to write it to the same value. In PHP version 5, an object variable doesn't contain the object itself as its value. It holds an object identifier that allows object accessors to find the actual object.When an object is sent by an argument, returned or assigned to a different variable, these different variables are not aliases. They contain a copy of the identifier, that points to the same object.Example$my_var = new class_name; echo $my_var->get_class_name(5)->value; $my_var->test(); echo $my_var->get_class_name(5)->value;OutputThis will produce the following output −class_name #5This isn't "pass by reference". It ... Read More

Advertisements