Purpose of Unions in C/C++

Ankith Reddy
Updated on 25-Jun-2020 10:04:03

4K+ Views

Union is a user-defined datatype. All the members of union share same memory location. Size of union is decided by the size of largest member of union. If you want to use same memory location for two or more members, union is the best for that.Unions are similar to structures. Union variables are created in same manner as structure variables. The keyword “union” is used to define unions in C language.Here is the syntax of unions in C language, union union_name {    member definition; } union_variables;Here, union_name  − Any name given to the union.member definition  − Set of member ... Read More

What Does 'do' Do in C/C++

Arjun Thakur
Updated on 25-Jun-2020 10:03:05

2K+ Views

The operator ‘?’ is known as ternary operator as it requires three operands to act upon. It can be represented by “ ? : ”. It is also known as conditional operator. The operator improves the performance and reduces the lines of code.Here is the syntax of ternary operator in C language, Expression1 ? Expression2 : Expression3Here is an example of Ternary Operator in C language, Example Live Demo#include int main() {    int a = -1;    double b = 26.4231;    int c = a? printf("True value : %lf", b):printf("False value : 0");    return 0; }OutputHere ... Read More

CSS quotes Property

Samual Sam
Updated on 25-Jun-2020 10:01:05

110 Views

Use the quotes property to set quotation marks. You can try to run the following code to implement the quotes propertyExampleLive Demo                    #demo {             quotes: "'" "'";          }                                           This is demo text surrounded by quotes.                    

Convert ArrayList to Array with Zero-Length Array in Java

karthikeya Boyini
Updated on 25-Jun-2020 09:59:33

239 Views

An ArrayList can be converted into an Array using the java.util.ArrayList.toArray() method. This method takes a single parameter i.e. the array of the required type into which the ArrayList elements are stored and it returns an Array that contains all the elements of the ArrayList in the correct order.A program that demonstrates this is given as follows −Example Live Demoimport java.util.ArrayList; import java.util.List; public class Demo {    public static void main(String[] args) {       List aList = new ArrayList();       aList.add("James");       aList.add("Harry");       aList.add("Susan");       aList.add("Emma");       ... Read More

ArrayBuffer.isView Function in JavaScript

karthikeya Boyini
Updated on 25-Jun-2020 09:57:17

244 Views

ArrayBuffer object in JavaScript represents a fixed-length binary data buffer. The isView() function of this object accepts an argument and verifies whether it is view of ArrayBuffer (DataView, typed array). If so, it returns true else, it returns false.SyntaxIts syntax is as followsarrayBuffer.isView(arg)ExampleTry the following example. Live Demo    JavaScript Example           var arrayBuffer = new ArrayBuffer(5);       arrayBuffer = ["apple", "orange", "mango"];       var bool = ArrayBuffer.isView(new Int32Array())       document.write(bool);     OutputtrueExampleIn the same way if we try executing this function by passing an object ... Read More

ArrayBuffer Slice Function in JavaScript

Samual Sam
Updated on 25-Jun-2020 09:56:41

527 Views

ArrayBuffer object in JavaScript represents a fixed-length binary data buffer.The slice() method of the this object returns a portion or, chunk from the array buffer (as a separate object). It accepts two integer arguments representing the start (inclusive) and end (exclusive) of the portion of the array to be returned.SyntaxIts syntax is as followsarrayBuffer.slice(start, end);ExampleTry the following example. Live Demo    JavaScript Example           var arrayBuffer = new ArrayBuffer(16);       var int32View = new Int32Array(arrayBuffer);       int32View[1] = 102;       var sliced = new Int32Array(arrayBuffer.slice(4,12));       document.write(" "+sliced);     Output102,0

Usage of CSS Visibility Property

Chandu yadav
Updated on 25-Jun-2020 09:56:20

148 Views

A property called visibility allows you to hide an element from view. You can use this property along with JavaScript to create very complex menu and very complex webpage layouts.The visibility property can take the values listed in the table that followsValueDescriptionvisibleThe box and its contents are shown to the user.hiddenThe box and its content are made invisible, although they still affect the layout of the page.collapseThis is for use only with dynamic table columns and row effects.ExampleYou can try to run the following code to learn how to work with visible and hidden values               ... Read More

Atomics Add Function in JavaScript

karthikeya Boyini
Updated on 25-Jun-2020 09:56:17

185 Views

The Atomic object of JavaScript is an object and which provides atomic operations such as add, sub, and, or, xor, load, store etc. as static methods, these methods are used with SharedArrayBuffer objects.The add() function of this object accepts a number and the position, adds the given number to the number in the given position and returns the value of the number in the old position.SyntaxIts syntax is as followsAtomics.add()Example Live Demo    JavaScript Example           var arrayBuffer = new SharedArrayBuffer(16);       var data = new Uint8Array(arrayBuffer);       data[0] = ... Read More

Copy All Elements of ArrayList to an Object Array in Java

Samual Sam
Updated on 25-Jun-2020 09:55:58

3K+ Views

All the elements of an ArrayList can be copied into an Object Array using the method java.util.ArrayList.toArray(). This method does not have any parameters and it returns an Object Array that contains all the elements of the ArrayList copied in the correct order.A program that demonstrates this is given as follows −Example Live Demoimport java.util.ArrayList; import java.util.List; public class Demo {    public static void main(String[] args) {       List aList = new ArrayList();       aList.add("Nathan");       aList.add("John");       aList.add("Susan");       aList.add("Betty");       aList.add("Peter");       Object[] objArr ... Read More

Atomics and Function in JavaScript

Samual Sam
Updated on 25-Jun-2020 09:55:53

192 Views

The Atomic object of JavaScript is an object and which provides atomic operations such as add, sub, and, or, xor, load, store etc. as static methods, these methods are used with SharedArrayBuffer objects.The and() function of the Atomic object accepts a value representing the position of an array, performs bitwise AND operation on the value in the given position and returns the old value in it.SyntaxIts syntax is as followsAtomics.and()Example Live Demo    JavaScript Example           var arrayBuffer = new SharedArrayBuffer(16);       var data = new Uint8Array(arrayBuffer);       data[0] = ... Read More

Advertisements