The HTML DOM Fieldset form property returns the form reference of the type form object. This is for the element that is present inside that given form. It is a read-only property. If the specified fieldset isn’t present inside the form then null is returnedSyntaxFollowing is the syntax for the fieldset form property −fieldsetObject.formExampleLet us look at an example for the fieldset form property − function formId() { var field = document.getElementById("FieldSet1").form.id; document.getElementById("Sample").innerHTML = "The id of the form in which fieldset element is present is ... Read More
The HTML DOM exitFullscreen() method is used for getting an element currently in the full screen mode to get out of that mode. It does nothing if executed on an element that isn’t in the full screen mode already.SyntaxFollowing is the syntax for exitFullscreen() method −HTMLElementObject.exitFullscreen()ExampleLet us look at an example for the exitFullscreen() method − var docEle = document.documentElement; function GoNormal() { if (document.exitFullscreen) document.exitFullscreen(); } function GoFullscreen() { if (docEle.requestFullscreen) docEle.requestFullscreen(); } exitFullscreen() method example ... Read More
Operator overloading is an important concept in C++. It is a type of polymorphism in which an operator is overloaded to give user-defined meaning to it. The overloaded operator is used to perform the operation on the user-defined data type. For example, '+' operator can be overloaded to perform addition on various data types, like for Integer, String(concatenation), etc.Input10 20 20 30Output30 50ExplanationTo perform addition of two numbers using ‘-‘ operator by Operator overloading. Binary operators will require one object as an argument so they can perform the operation. If we are using Friend functions here then it will need ... Read More
Given a, b and n. And we have to consider the following conditions and find the optimal solution to add n digits to a such that it is divisible by b after every iteration.Add a digit to a in such a way that after adding it, a is divisible by b.Print the smallest value of a possible after n iterations of step1.Print fail if the operation fails.check divisibility after every digit addition.Inputa=5 b=4 n=4Output52000ExplanationThe first digit to be added from 0 to 9, if none of the digits make a divisible by b then the answer is -1 which means the if n digits are ... Read More
In this section we will see how we can read file content word by word using C++. The task is very simple. we have to use the file input stream to read file contents. The file stream will open the file by using file name, then using FileStream, load each word and store it into a variable called word. Then print each word one by one.Algorithmread_word_by_word(filename)begin file = open file using filename while file has new word, do print the word into the console done endFile Content (test_file.txt)This is a test file. There are ... Read More
The program to find the area of a square inscribed in a circle which itself is inscribed in an equilateral triangle. The radius of circle inscribed inside an equilateral is a/(2√3).The diameter of circle is the diagonal of square, d = 2 * r = a/ √3 Area formula for area of square given its diagonals is ½ d2, A = 0.5 * d2 A = (1/2) * (a2) / (3) = (a2/6) Example#include using namespace std; int main() { float area,a = 10; area = (a*a) / 6; cout
The HTML DOM console.time() method is used for displaying the time elapsed in executing a piece of code. This helps us in analyzing the entire code or specific bits of our code. By timing your code you can make it more efficient. Using the optional label parameter you can create several timers on the same page.SyntaxFollowing is the syntax for HTML DOM console.time() method −console.time(label)Here, the label is an optional parameter to give our timer a name.ExampleLet us look at an example for the console.time() method − console.time() Method Click the below button to time the for, while ... Read More
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
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
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
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP