C++ Program to Print Current Day, Date and Time

sudhir sharma
Updated on 19-Sep-2019 07:35:01

2K+ Views

Current day, date and time are all calendar dates that are printed on screen. In c++, the ctime library contains all the methods and variables related to date and time.You can also check current date and time details using the ctime library which contains methods to display time. The following methods are used to display details of date and time −time() − The time() method is used to find the current time. The return time of the time() method is time_t. time_t is the data type that can store time.localtime() − To convert the time_t type variables to a variable ... Read More

Usage of Split Method in JavaScript

Ayush Gupta
Updated on 19-Sep-2019 07:33:18

248 Views

The split([separator, [limit]]) method splits a String object into an array of strings by separating the string into substrings, using a specified separator string to determine where to make each split.Example usage of split methodlet a = "hello, hi, bonjour, namaste"; let greetings = a.split(', '); console.log(greetings)Output[ 'hello', 'hi', 'bonjour', 'namaste' ]Note that the commas were removed here. Any separator provided will be removed.If separator is an empty string, str is converted to an array having one element for each character of str.Examplelet a = "hello"; console.log(a.split(""))Output[ 'h', 'e', 'l', 'l', 'o' ]If no separator is provided, the string is ... Read More

Find the Type of Given Iterator in C++

sudhir sharma
Updated on 19-Sep-2019 07:30:27

225 Views

An iterator is an object just like a pointer that is used to iterate over elements of a container. The main advantage of using an iterator is to create a common interface and make the algorithm immune from the type of container used to implement it.In C++ standard library there are Types of iterators −Forward iteratorBidirectional iteratorInput iteratorOutput iteratorRandom Access iteratorThe program is to check which of the above iterators are used by the data structure.There are a few factors that can be useful for determining the type of iterator used.typeid, returns the type identification information at runtime.iterator traits, defines ... Read More

Sort Dates Using Selection Sort in C++

sudhir sharma
Updated on 19-Sep-2019 07:27:31

980 Views

Date is number day, month and year. There are various ways to display a date.Here, we have a program to sort dates using selection sort. So let's learn about things that are used in this concept.Sorting datesThe concept of sorting dates needs a clear and well-versed knowledge of dates and their validations. Before we try sorting technique we need to check if the date inputted by the user is a valid date of not like 29-2 is only valid for leap years.After validation of dates comes the sorting of dates. For sorting, we will go in reverse order sorting years ... Read More

C++ Program for Longest Common Subsequence

sudhir sharma
Updated on 19-Sep-2019 07:16:44

3K+ Views

A subsequence is a sequence with the same order of the set of elements. For the sequence “stuv”, the subsequences are “stu”, “tuv”, “suv”, .... etc.For a string of length n, there can be 2n ways to create subsequence from the string.ExampleThe longest common subsequence for the strings “ ABCDGH ” and “ AEDFHR ” is of length 3. Live Demo#include #include using namespace std; int max(int a, int b); int lcs(char* X, char* Y, int m, int n){    if (m == 0 || n == 0)       return 0;    if (X[m - 1] == ... Read More

Convert String to Camel Case in JavaScript

Ayush Gupta
Updated on 19-Sep-2019 07:15:02

1K+ Views

Camel case is the practice of writing phrases such that each word or abbreviation in the middle of the phrase begins with a capital letter, with no intervening spaces or punctuation. For example, Concurrent hash maps in camel case would be written as −ConcurrentHashMapsWe can implement a method to accept a string in JavaScript to convert it to camel case in the following way −Examplefunction camelize(str) {    // Split the string at all space characters    return str.split(' ')       // get rid of any extra spaces using trim       .map(a => a.trim())     ... Read More

C++ Program for Hashing with Chaining

sudhir sharma
Updated on 19-Sep-2019 07:13:39

2K+ Views

Hashing is the method by which we can map any length data element to a fixed size key. hashing works as key-value pairs.Hashing function is the function that does the mapping in a hash map. the data elements that are given as input to the Hash Function may get same hash key. In this case the elements may overlap. To avoid overlapping of elements which have the same hash key the concept of chaining was introduced.Creating a hashmapIn order to create a hashmap we need hashing function that will define the index value of the data element.We have a hash ... Read More

C++ Mathematical Functions

sudhir sharma
Updated on 19-Sep-2019 07:05:50

3K+ Views

Mathematical calculations can be done in C++ programming language using the mathematical functions which are included in math or cmath library. These mathematical functions are defined to do complex mathematical calculations. Let’s learn each of them one by one −sineThe sin method is used to calculate the sin of the angle given as an argument in degrees. This function accepts one double integer as an argument and returns a double integer which is the value of sin(x°).double sin(double)Calling syntaxdouble x = sin(23.4);Example Live Demo#include #include using namespace std; int main(){    double x = 45.3;    cout

Why Using for..in with Array Iteration is a Bad Idea in JavaScript

Ayush Gupta
Updated on 19-Sep-2019 06:57:52

154 Views

Using for..in loops in JavaScript with array iteration is a bad idea because of the following behavior −Using normal iteration loops −Examplelet arr = [] arr[4] = 5 for (let i = 0; i < arr.length; i ++) {    console.log(arr[i]) }Outputundefined undefined undefined undefined 5If we had iterated over this array using the for in construct, we'd have gotten −Examplelet arr = [] arr[4] = 5 for (let i in arr) {    console.log(arr[i]) }Output5Note that the length of the array is 5, but this still iterates over only one value in the array.This happens because the purpose of ... Read More

C++ Map with User-Defined Data Type as Key

sudhir sharma
Updated on 19-Sep-2019 06:52:55

1K+ Views

A map is a data structure that stores information in the form of key and value pairs. In C++, map is defined in STL (standard template library) and store keys in an ordered form.Syntax to define a map −map map_name;The data type of any of these two data of the map can be any of the data types. We can have any of the primary data types or derived data types as key or value data types in a map.We can use any of the data types as the data type of the key of the map. Even a user-defined ... Read More

Advertisements