HTML DOM Console Group Method

AmitDiwan
Updated on 13-Aug-2019 09:03:19

141 Views

The HTML DOM console.group() method is used to indicate the start of message group and all messages written after this method will be written inside the message group. This allows making one group for all messages or several groups using the label parameter.SyntaxFollowing is the syntax for the console.group() method −console.group([label])Here, label is an optional parameter. It is of type string and acts as a label for the message group created.ExampleLet us look at an example for the HTML DOM console.group() method − console.group() Method Press F12 key to view the message in the console view. NORMAL GROUP ... Read More

HTML DOM console.timeEnd() Method

AmitDiwan
Updated on 13-Aug-2019 08:45:10

96 Views

The console.timeEnd() method is used for stopping the timer and displaying the time elapsed while the code inside the console.time() and console.timeEnd() took to finish execution. It is useful for timing sections of your code to figure out where the bottlenecks are. Using the optional label parameter we can specify which timer to stop.SyntaxFollowing is the syntax for console.timeEnd() method −console.timeEnd(label);Here, label is an optional parameter for specifying which timer to stop.ExampleLet us look at an example for the console.timeEnd() method − console.time() Method Click the below button to time the for, while and do-while loops for 100000 ... Read More

Area of a N-Sided Regular Polygon with Given Radius in C Program

sudhir sharma
Updated on 13-Aug-2019 08:27:29

413 Views

A polygon is a ‘n’ sided closed figure.N sided polygon means a polygon with n equal sides. The radius of a polygon is distance between center and vertex.In the figure we can see that the whole polygon can be divided into n equal polygonWe know, area of the triangle = (base * height)/2Area of the small triangle using trigonometric logic, area = r2*sin(t)cos(t) = (r2*sin(2t))/2So, area of the polygon:Area = n * (area of one triangle)= n*r2*sin(2t)/2 = n*r2*sin(360/n)/2Example#include #include int main() {    float r = 4 n = 12;    float area = ((r * r ... Read More

Superperfect Number in C Programming

sudhir sharma
Updated on 13-Aug-2019 07:50:54

545 Views

The concept of super perfect number is similar to the perfect number. It was found by D Suryanarayana in 1969. He generalized the super perfect number as a number that satisfies the following formula :sig(sig(n)) = 2nHere, sig(n) is the function that calculates the sum of divisors of a number, it is also known as divisor summatory function.The following example with making this concept clear to you :we need to check if the number N is a superperfect number or not:N = 16OutputyesExplanation − to check whether a number is a perfect number or not we will find the sum ... Read More

Super Prime in C Programming

sudhir sharma
Updated on 13-Aug-2019 07:49:34

2K+ Views

A super-prime number is A number that occupies prime number position in the sequence of all prime numbers. also known as high order primes, These numbers occupy the position in the sequence of prime number which is equal to Prime number. some super prime numbers are 3, 5, 11, 1 7…For Example let us Find all super prime numbers less than 13 -Input 13Output3, 5, 11.Explanation − to find the super prime number less than 13 we will find all prime numbers that are less than 13. So, show all prime numbers less than 13 are 2, 3, 5, 7, 11, ... Read More

C++ Program for Nth Catalan Number

sudhir sharma
Updated on 13-Aug-2019 06:45:25

613 Views

Catalan numbers are a sequence of numbers. Catalan numbers form a sequence of natural numbers that occur in various counting problems, often involving recursively-defined objects.Cn is the number of Dyck words of length 2n. A Dyck word is a string consisting of n X's and n Y's such that no initial segment of the string has more Y's than X's. For example, the following are the Dyck words of length 6XXXYYY XYXXYY XYXYXY XXYYXY XXYXYY.Re-interpreting the symbol X as an open parenthesis and Y as a close parenthesis, Cn counts the number of expressions containing n pairs of parentheses which ... Read More

Add Minimum Number to an Array for Even Sum in C Programming

sudhir sharma
Updated on 09-Aug-2019 13:22:25

235 Views

Given an array, add the minimum number (which should be greater than 0) to the array so that the sum of array becomes even.Input - 1 2 3 4, Output - 2Explanation - Sum of array is 10, so we add minimum number 2 to make the sum even.Method 1: calculate the sum of all elements of the array, then check if the sum is even then add minimum number is 2, else add minimum number is 1.Input - 1 2 3 4, Output - 2Explanation - Sum of array is 10, so we add minimum number 2 to make the sum even.Example#include using namespace std; int ... Read More

Arithmetic Mean in C Programming

sudhir sharma
Updated on 09-Aug-2019 13:15:22

3K+ Views

Arithmetic mean is the sum of a collection of numbers divided by the number of numbers in the collection.Basic properties of Arithmetic MeanThe mean of n numbers x1, x2, . . ., xn is x. If each observation is increased by p, the mean of the new observations is (x + p).The mean of n numbers x1, x2, . . ., xn is x. If each observation is decreased by p, the mean of the new observations is (x - p).The mean of n numbers x1, x2, . . ., xn is x. If each observation is multiplied by a nonzero ... Read More

C++ Program for Dijkstra's Shortest Path Algorithm

sudhir sharma
Updated on 09-Aug-2019 13:08:53

16K+ Views

Dijkstra's algorithm (or Dijkstra's Shortest Path First algorithm, SPF algorithm) is an algorithm for finding the shortest paths between nodes in a graph, which may represent, for example, road networks. The algorithm creates a tree of shortest paths from the starting vertex, the source, to all other points in the graph.Dijkstra’s algorithm finds a shortest path tree from a single source node, by building a set of nodes that have minimum distance from the source.The graph has the following−vertices, or nodes, denoted in the algorithm by v or u.weighted edges that connect two nodes: (u, v) denotes an edge, and ... Read More

Check if All Digits of a Number Divide It in C

sudhir sharma
Updated on 09-Aug-2019 12:33:53

764 Views

For a number n given, we need to find whether all digits of n divide it or not i.e. if a number is ‘xy’ then both x and y should divide it.SampleInput - 24 Output - Yes Explanation  - 24 % 2 == 0, 24 % 4 == 0Using conditional statements checking if each digit is non-zero and divides the number. We need to iterate over each digit of the number. And the check for the divisibility of the number for that number.Example#include int main(){    int n = 24;    int temp = n;    int flag=1;    while (temp > ... Read More

Advertisements