HTML DOM Image Object

karthikeya Boyini
Updated on 30-Jul-2019 22:30:26

527 Views

The HTML DOM image Object represents the element of an HTML document.Let us create an img object −SyntaxFollowing is the syntax −document.createElement(“IMG”);PropertiesFollowing are the properties of image Object −PropertyExplanationaltIt returns and modify the value of the alt attribute of an image HTML element.completeIt returns whether the browser finished loading an image in HTML web page or not.crossOriginIt returns and modify the CROS setting of an image HTML element.heightIt returns and modify the value of the height attribute of an image HTML element.naturalHeightIt returns the natural height of an image in HTML document.naturalWidthIt returns the natural width of an image ... Read More

HTML DOM Input Datetime Local Value Property

AmitDiwan
Updated on 30-Jul-2019 22:30:26

146 Views

The HTML DOM Input DatetimeLocal value property returns a string, which is the value of the value attribute of input datetimeLocal. User can also set it to a new string.SyntaxFollowing is the syntax −Returning string valueinputDatetimeLocalObject.valueSetting value attribute to a string valueinputDatetimeLocalObject.value = ‘String’ExampleLet us see an example of Input DatetimeLocal value property − Live Demo Input DatetimeLocal value    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {     ... Read More

Print N Numbers Such That Their Sum is a Perfect Square

Sunidhi Bansal
Updated on 30-Jul-2019 22:30:26

194 Views

Given with n numbers program must find those n number whose sum is a perfect squareInput : 5 Output : 1 3 5 7 9 1+3+5+7+9=25 i.e (5)^2AlgorithmSTART    Step 1 : Declare a Macro for size let’s say of 5 and i to 1    Step 2: loop While till i printing (2*i)-1 Step       Step 2.2 -> incrementing i with 1 Step    Step3-> End loop While STOPExample#include # define SIZE 5 int main() {    int i=1;    while(i

One-Line C Function to Round Floating Point Numbers

Smita Kapse
Updated on 30-Jul-2019 22:30:26

789 Views

Here we will see how to write one-line C function, that can round floating point numbers. To solve this problem, we have to follow these steps.Take the numberif the number is positive, then add 0.5Otherwise, subtract 0.5Convert the floating point value to an integer using typecastingExample#include    int my_round(float number) {    return (int) (number < 0 ? number - 0.5 : number + 0.5); } int main () {    printf("Rounding of (2.48): %d", my_round(2.48));    printf("Rounding of (-5.79): %d",my_round(-5.79)); }OutputRounding of (2.48): 2 Rounding of (-5.79): -6

Generate All Pairs of Subsets Whose Union Makes the Set in C++

Samual Sam
Updated on 30-Jul-2019 22:30:26

299 Views

This is a C++ program to generate all pairs of subsets, whose union make the Set.AlgorithmsBegin    function UnionSet():    Arguments:       a[] = an array.       n = number of elements.       Body of the function:       1) Generate binary code from 0 to 2^(n-1)-1 for all 2^(n-1) pairs.       2) Print the array element which has 0 or 1 in corresponding indexes in code string for each code.       3) Print them in a different set, which on the union of both sets gives the super set. EndExample#include #include #include using namespace std; void display(char code[], int a[], int n) //display the pairs {    int i;    cout

Create a User in MongoDB

Smita Kapse
Updated on 30-Jul-2019 22:30:26

216 Views

To create a user in MongoDB v3, use the createUser() method. This allows you to create a user and while creating you need to add user, password, and roles as well. These roles assign permissions. The syntax is as follows −use admin db.createUser(    {       user: “yourUserName",       pwd: "yourPassword",       roles: [ { role: "yourPermission", db: "yourDatabase" } ]    } );Let us implement the above syntax in order to create a user In MongoDB v3 −> use admin switched to db admin > db.createUser( ...    { ...       ... Read More

Clear to Send RTS

Ankith Reddy
Updated on 30-Jul-2019 22:30:26

4K+ Views

Clear to Send (CTS) is a control frame employed in the medium access control (MAC) layer protocol IEEE 802.11 RTS/CTS. The protocol uses the concept of Multiple Access with Collision Avoidance (MACA) in wireless networks. The RTS/CTS (Request to Send / Clear to Send) mechanism aims to reduce frame collisions introduced by the hidden terminal problem. CTS frame is sent by the receiver after it gets the RTS frame prior to receiving of the actual data frame.Working Principle of MACA implementing CTSThe MACA protocol works with the condition that the communicating stations are synchronized and frame sizes and data speed ... Read More

Disallow Resizing Component with GridBagLayout in Java

Anvi Jain
Updated on 30-Jul-2019 22:30:26

867 Views

To disallow resizing component with GridBagLayout, use the GridBagConstraints NONE constant −GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.NONE;The following is an example to disallow resizing component with GridBagLayout −Examplepackage my; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.WindowConstants; public class SwingDemo {    public static void main(String[] args) {       JFrame frame = new JFrame("Demo Frame");       JPanel panel = new JPanel();       GridBagLayout layout = new GridBagLayout();       panel.setLayout(layout);       GridBagConstraints gbc = new GridBagConstraints();       gbc.fill = GridBagConstraints.NONE;   ... Read More

HTML DOM Input Email Autocomplete Property

AmitDiwan
Updated on 30-Jul-2019 22:30:26

190 Views

The HTML DOM Input Email autocomplete property sets/returns whether autocomplete is enabled or disabled. If enabled, it shows previously typed values.SyntaxFollowing is the syntax −Returning value - on/offinputEmailObject.autocompleteSetting autocomplete to valueinputEmailObject.autocomplete = valueValuesHere, “value” can be the following −valueDetailsonIt defines that input has autocomplete enabled, it is also the default.offIt defines that input autocomplete attribute is disabled.ExampleLet us see an example of Input Email autocomplete property − Live Demo Input Email autocomplete    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       ... Read More

Print Number of Words, Vowels and Frequency of Each Character

Sunidhi Bansal
Updated on 30-Jul-2019 22:30:26

356 Views

Input a string and find the total number of words, vowels and frequency of a character enter by a userInput : enter s string : I love my MOM      Enter a charcter of which you want to find a frequency: M    Total frequency of M : 2    Total number of vowels : 4    Total number of words : 4AlgorithmSTART Step 1 Declare array of string, ch, i, freq to 0, vow to 0, word to 0 Step 2 Input a string and a character ch Step 3 Loop for from i to 0 and str[i]!=’\o’ ... Read More

Advertisements