In this article we will be discussing the working, syntax and examples of forward_list::merge() function in C++.What is a Forward_list in STL?Forward list are sequence containers that allow constant time insert and erase operations anywhere within the sequence. Forward list are implement as a singly-linked lists. The ordering is kept by the association to each element of a link to the next element in the sequence.What is forward_list::merge()?forward_list::merge() is an inbuilt function in C++ STL which is declared in header file. merge() is used to merge two sorted forward_list into one. Before merging two lists we must ensure the lists are ... Read More
Given is the task to show the working of forward_list max_size() function in C++ STL.What is a Forward List?Forward list can be understood as a singly linked list where the tracking can be done only in forward direction but not in a backward direction whereas in the list we can track the elements in both the direction i.e. the element holds the two links one is for forward element and another one is for backward element. Forward lists are therefore fast because they have to hold only one link which will be of a forward element. Forward elements can be ... Read More
In this article we will be discussing the working, syntax and examples of list::empty() function in C++.What is a List in STL?List is a data structure that allows constant time insertion and deletion anywhere in sequence. Lists are implemented as doubly linked lists. Lists allow non-contiguous memory allocation. List perform better insertion extraction and moving of element in any position in container than array, vector and deque. In List the direct access to the element is slow and list is similar to forward_list, but forward list objects are single linked lists and they can only be iterated forwards.What is list::empty()?list::empty() ... Read More
Given is the task to show the working of ratio_less_equal () function in c++.The given function Ratio_less_equal checks if the value of ratio1 is less or equal than ratio2. It returns a Boolean constant “value” which returns true if ratio1 is less or equal than ratio2 else returns false.Syntaxtemplate ratio_less_equalParametersThis function accepts two template parameters one is ratio1 and another one is ratio2 which are to be compared.Explanation of this functionIn this function, if the value of ratio1 is less than or equal to the value of ratio2 then this function will return the Boolean value which is true i.e. ... Read More
The fill() method in JavaScript is used to fill elements with static value in an array. The following are the parameters for fill() −value− The value to be filled.begin− The start index to begin filling the array.end− The ending index to stop filling the array.ExampleYou can try to run the following code to learn how to work with fill() method on JavaScript − var num = ["One", "Two", "Three", "Four", "Five"]; document.write(num); document.write(""+num.fill("Six",2,3));
The Date object is a datatype built into the JavaScript language. Date objects are created with the new Date( ) as shown below.Once a Date object is created, a number of methods allow you to operate on it. Most methods simply allow you to get and set the year, month, day, hour, minute, second, and millisecond fields of the object, using either local time or UTC (universal, or GMT) time.You can use any of the following syntaxes to create a Date object using Date() constructor −new Date( ) new Date(milliseconds) new Date(datestring) new Date(year, month, date[, hour, minute, second, millisecond ])The ... Read More
LCM (Least common multiple) of two (or more) numbers is a number which is the smallest number that is divisible by both (or all).First we find the larger number of two given numbers. Starting from it we try and find the first number that is divisible by both, which is LCMExamplex=12 y=20 if x > y: greater = x else: greater = y while(True): if((greater % x == 0) and (greater % y == 0)): lcm = greater break greater += 1 print ("LCM of {} and {}={}".format(x,y,lcm))OutputThe result is −LCM of 12 and 20=60
Let us first create a table −mysql> create table DemoTable1605 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(20), -> StudentCountryName varchar(20) -> ); Query OK, 0 rows affected (0.48 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1605(StudentName, StudentCountryName) values('Adam', 'AUS'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1605(StudentName, StudentCountryName) values('John', 'US'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable1605(StudentName, StudentCountryName) values('Bob', 'UK'); Query OK, 1 row affected (0.11 sec)Display all records from the table using select statement −mysql> select ... Read More
Let us first create a table −mysql> create table DemoTable -> ( -> Name varchar(20), -> Amount int -> ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John', 200); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('Chris', 150); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('Mike', 500); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('John', 350); Query OK, 1 row affected (0.18 sec)Display all records from the table using select statement −mysql> ... Read More
Let us first create a table −mysql> create table DemoTable -> ( -> Id int, -> Name varchar(20), -> Age int, -> CountryName varchar(10) -> ); Query OK, 0 rows affected (0.81 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100, 'Chris', 34, 'AUS'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values(101, 'Chris', 31, 'US'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values(102, 'David', 25, 'UK'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(103, 'Carol', 28, 'AUS'); ... Read More