HTML DOM fullscreenEnabled Method

AmitDiwan
Updated on 20-Aug-2019 07:20:46

141 Views

The HTML DOM fullscreenEnabled() method is used for specifying if the fullscreen mode is available or not for the current document. Its return type is boolean and is a read-only property. True is returned if the fullscreen mode is available otherwise it returns false. Different prefixes are used to make it work with your browser.SyntaxFollowing is the syntax for fullscreenEnabled() method −document.fullscreenEnabled()Let us look at an example for the fullscreenEnabled() method −Note − You will need to use your browser prefix for fullscreenEnabled() method to work. Check the note at the last to have your browser specific prefix.ExampleLet us see ... Read More

Addition and Subtraction of Matrix Using Pthreads in C/C++

Arnab Chakraborty
Updated on 20-Aug-2019 07:19:09

963 Views

Here we will see how to perform the matrix addition and subtraction using multithreaded environment. The pthread is used to execute multiple threads simultaneously in C or C++.There are two matrices A and B. Order of each matrix is (m x n). Each thread will take each row, and perform addition or subtraction. So for m rows, there are m different threads.Example#include #include #include #include #define CORE 3 #define MAX 3 using namespace std; int AMat[MAX][MAX] = {{10, 20, 30},    {40, 50, 60},    {70, 80, 50} }; int BMat[MAX][MAX] = {{80, 60, 20},    {30, ... Read More

Find Sum of Series with N-th Term as n^2 - (n-1)^2 in C++

Arnab Chakraborty
Updated on 20-Aug-2019 07:15:14

192 Views

Here we will see how to get the sum of the series with n-th term as n2 – (n-1)2. The recurrence relation is like below −Tn = n2 − (n−1)2So the series is −We need to find S mod (109 + 7), where S is the sum of all terms of the given series.Example#include #define X 1000000007 using namespace std; long long getSum(long long n) {    return ((n % X) * (n % X)) % X; } int main() {    long long n = 56789;    cout

Hidden Tricks of C++ Related to STL

Arnab Chakraborty
Updated on 20-Aug-2019 07:07:31

277 Views

Here we will see some hidden tricks of C++ related to STL.Assign value of pairs using braces ‘{}’. We can use them to assign into tuples also.pair my_pair = make_pair(10, 20); pair my_pair2 = { 10, 20 }; //using braces pair my_pair3 = { 10, { 'A', 20 } }; //complex pairSometimes we do not remember to include lots of headers, or sometimes we forget the names of the headers, in that time we can follow this trick to include all headers.#include C++ has inbuilt GCD function. That function is not so popular so we do not know about it. ... Read More

Add All Greater Values to Every Node in the Given BST

Arnab Chakraborty
Updated on 20-Aug-2019 07:04:27

185 Views

Here we will see one interesting problem, where we will add greater values to every node in one given binary search tree. So the initial and final tree will be look like below −AlgorithmbstUpdate(root, sum) −Begin    if root is null, then stop    bstUpdate(right of room, sum)    sum := sum + value of root    update root value using sum    bstUpdate(left of room, sum) EndExample#include using namespace std; class Node {    public:       int data;       Node *left, *right;    };    Node *getNode(int item) {       Node *newNode = ... Read More

Types of Polymorphisms: Ad-Hoc Inclusion, Parametric, and Coercion

Arnab Chakraborty
Updated on 20-Aug-2019 07:01:05

4K+ Views

Here we will see different types of polymorphism. The types are −Ad-HocInclusionParametricCoercionThe Ad-Hoc polymorphism is called as overloading. This allows function with same name to act in different manner for different types. The function and the operator both can be overloaded. Some language does not support operator overloading, but function overloading is common.Example#include using namespace std; int add(int a, int b) {    return a + b; } string add(string a, string b) {    return a + b; //concatenate } int main() {    cout

HTML DOM Form Target Property

AmitDiwan
Updated on 20-Aug-2019 07:00:30

290 Views

The HTML DOM Form target property is used for specifiying where the response should be displayed after the form data has been submitted. It could display in a new tab, current tab or a new window. The form target property set or gets the target attribute value.SyntaxFollowing is the syntax for −Setting the target property −formObject.target = "_blank|_self|_parent|_top|framename"Here, _blank will open the response in new window, _self will open the response in the same window; parent will open in the parent frame, _top will open in full window body and framename will open it in a specified named frame.ExampleLet us ... Read More

A Puzzle Using C Program

Arnab Chakraborty
Updated on 20-Aug-2019 06:57:35

726 Views

Here we will see one C puzzle question. Suppose we have two numbers 48 and 96. We have to add the first number after the second one. So final result will be like 9648. But we cannot use any logical, arithmetic, string related operations, also cannot use any pre-defined functions. So how can we do that?This is easy. We can do by using Token Pasting operator(##) in C. The Token Pasting operator is a preprocessor operator. It sends commands to compiler to add or concatenate two tokens into one string. We use this operator at the macro definition.Example#include #define MERGE(x, ... Read More

3-Way QuickSort Dutch National Flag

Arnab Chakraborty
Updated on 20-Aug-2019 06:56:42

2K+ Views

Here we will see the quicksort technique but we will use three-way quicksort. The basic quicksort technique is just finding an element as pivot then partition the array around pivot, after that, recur for sub arrays on left and right of the pivot.The three-way quicksort is similar, but there are three sections. array arr[1 to n] is divided into three parts.arr[1 to i]arr[i + 1, j]arr[j + 1, n]Algorithmpartition(arr, left, right, i, j) −begin    if right – left

HTML DOM Storage removeItem Method

AmitDiwan
Updated on 20-Aug-2019 06:05:15

161 Views

The HTML DOM Storage removeItem() method is used for removing a storage object item by passing a given key name.SyntaxFollowing is the syntax for Storage removeItem() method −localStorage.removeItem(keyname);ORsessionStorage.removeItem(keyname);Here, keyname is of type string and represents the name of the item to be removed.ExampleLet us look at the example for the Storage removeItem() method − Storage removeItem() method example Delete the localstorage item by clicking the below button DISPLAY    localStorage.setItem("TEXT1", "HELLO WORLD");    function itemDelete() {       localStorage.removeItem("TEXT1");       itemShow();    }    function itemShow() {       var x = ... Read More

Advertisements