Structs in Arduino Program

Yash Sanghvi
Updated on 15-Sep-2023 02:21:17

45K+ Views

A struct is simply a collection of different types of variable. Structs in Arduino mimic the structs in C language. So, if you are familiar with C structs, Arduino structs shouldn’t be an issue. The struct declaration syntax is as follows −Syntaxstruct structName{    item1_type item1_name;    item2_type item2_name;    .    .    .    itemN_type itemN_name; }An example is given below −Examplestruct student{    String name;    int age;    int roll_no; }The elements of a struct are accessed using the . (dot) notation. This notation can be used for both reading the elements of a struct, or changing ... Read More

Differences Between Procedural and Object-Oriented Programming

Kiran Kumar Panigrahi
Updated on 15-Sep-2023 02:20:07

39K+ Views

Both Procedural Programming and Object Oriented Programming are high-level languages in programming world and are widely used in the development of applications. On the basis of nature of developing the code, both languages have different approaches on basis of which both are differentiate from each other. In this article, we will discuss the important differences between procedural oriented programming and object oriented programming. But before going into the differences, let's start with some basics. What is Procedural Programming? Procedural Programming is a programming language that follows a step-by-step approach to break down a task into a collection of variables ... Read More

Enter Key Press Event in JavaScript

AmitDiwan
Updated on 15-Sep-2023 02:16:05

26K+ Views

For ENTER key press event, you can call a function on −onkeypress=”yourFunctionName”Use the ENTER’s keycode 13.Example Live Demo Document    function enterKeyPressed(event) {       if (event.keyCode == 13) {          console.log("Enter key is pressed");          return true;       } else {          return false;       }    } To run the above program, save the file name "anyName.html (index.html)" and right click on the file. Select the option "Open with Live Server" in VS Code editor.OutputThis will produce the following output −On pressing ENTER key, the following output is visible on console −

Convert Array of Strings to Array of Numbers in JavaScript

Imran Alam
Updated on 15-Sep-2023 02:14:31

30K+ Views

In JavaScript, there are different ways to convert an array of strings to an array of numbers. The first way is to use the built-in parseInt() method, and the second way is to use a type conversion function, and the third one is to use the unary + operator.Using the parseInt() methodThe parseInt() method is a built-in function in JavaScript that takes a string as an argument and returns a number. This method can be used to convert an array of strings to an array of numbers.SyntaxThe syntax of the parseInt() method is as follows −parseInt(string, radix);ParametersString − The string ... Read More

Use XPath in Selenium WebDriver to Grab SVG Elements

Debomita Bhattacharjee
Updated on 15-Sep-2023 01:19:53

42K+ Views

We can use xpath to grab SVG elements with Selenium Webdriver. A SVG element is identified with tagname svg. The svg image has the attributes like width and height attributes.Let us investigate the html code of a svg element.To create a xpath for a svg element, we have the syntax as //*[local-name()='svg'].The local-name function is mandatory for creating a xpath of a svg element. So for the xpath expression for the image highlighted in the above image should be −//*[local-name()='svg' and @data-icon='home']/*[local-name()='path']Here, data-icon is an attribute of the svg tag element which is added accompanied with @ symbol. The [local-name()='path'] is ... Read More

Difference Between HashMap and HashSet in Java

Nitin Sharma
Updated on 15-Sep-2023 01:07:13

26K+ Views

HashMap and HashSet both are one of the most important classes of Java Collection framework.Following are the important differences between HashMap and HashSet.Sr. No.KeyHashMapHashSet1ImplementationHashmap is the implementation of Map interface.Hashset on other hand is the implementation of set interface.2Internal implementationHashmap internally do not implements hashset or any set for its implementation.Hashset internally uses Hashmap for its implementation.3Storage of elementsHashMap Stores elements in form of key-value pair i.e each element has its corresponding key which is required for its retrieval during iteration.HashSet stores only objects no such key value pairs maintained.4Method to add elementPut method of hash map is used to ... Read More

Wait Until an Element is Present in Selenium

Debomita Bhattacharjee
Updated on 15-Sep-2023 00:54:08

31K+ Views

We can wait until an element is present in Selenium Webdriver. This can be done with the help of synchronization concept. We have an explicit wait condition where we can pause or wait for an element before proceeding to the next step.The explicit wait waits for a specific amount of time before throwing an exception. To verify if an element is present, we can use the expected condition presenceOfElementLocated.ExampleCode Implementation.import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; public class ElementPresenceWait{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");     ... Read More

Difference Between Static and Dynamic Hashing

Manisha Shejwal
Updated on 14-Sep-2023 22:01:30

41K+ Views

Hashing is a computation technique in which hashing functions take variable-length data as input and issue a shortened fixed-length data as output. The output data is often called a "Hash Code", "Key", or simply "Hash". The data on which hashing works is called a "Data Bucket". Characteristics of Hashing Technique Hashing techniques come with the following characteristics − The first characteristic is, hashing technique is deterministic. Means, whatever number of times you invoke the function on the same test variable, it delivers the same fixed-length result. The second characteristic is its unidirectional action. There is no way you can ... Read More

Create a Vector with Repeated Values in R

Nizamuddin Siddiqui
Updated on 14-Sep-2023 22:00:00

36K+ Views

There are two methods to create a vector with repeated values in R but both of them have different approaches, first one is by repeating each element of the vector and the second repeats the elements by a specified number of times. Both of these methods use rep function to create the vectors.ExampleConsider the below examples −> x1 x1 [1] 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 [39] 4 ... Read More

Display Base64 Images in HTML

AmitDiwan
Updated on 14-Sep-2023 21:56:10

26K+ Views

To display images encoded with Base64, you need to get the base64 encoded string and use the img element. This prevents the page from loading slowly and saves the web browser from additional HTTP requests. Set the base64 image in the src attribute of the . Let’s say we have the following image − For Base64, we will consider the Data URL of the image, which is placed in the src attribute. The Data URL has two parts − The 1st part is the Base64 encoded image. The 2nd part is the Base64 encoded string of the image. ... Read More

Advertisements