Operator Precedence and Associativity in C

Nancy Den
Updated on 30-Jul-2019 22:30:25

10K+ Views

Operator precedence determines the grouping of terms in an expression and decides how an expression is evaluated. Certain operators have higher precedence than others; for example, the multiplication operator has a higher precedence than the addition operator.For example, x = 7 + 3 * 2; here, x is assigned 13, not 20 because operator * has a higher precedence than +, so it first gets multiplied with 3*2 and then adds into 7.Here, operators with the highest precedence appear at the top of the table, those with the lowest appear at the bottom. Within an expression, higher precedence operators will ... Read More

Handle Right to Left Swipe Gestures

Nitya Raut
Updated on 30-Jul-2019 22:30:25

696 Views

This example demonstrate about How to handle right to left swipe gesturesStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     In the above code, we have taken button view to handle swapsStep 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.content.ActivityNotFoundException; import android.content.Intent; import android.content.pm.ResolveInfo; import android.content.res.Configuration; import android.graphics.PixelFormat; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.WindowManager; import ... Read More

Generate Random Number Array and Get Min/Max Values in Java

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

1K+ Views

At first, create a double array −double[] val = new double[10];Now, generate and display random numbers in a loop that loops until the length of the above array. We have used nextInt here for random numbers −for (int i = 0; i < val.length; i++) {    val[i] = new Random().nextInt(100);    System.out.println(val[i]); }Now, get the min and max values. Compare each value of the random array with the MIN and MAX values −double min = Double.MAX_VALUE; double max = Double.MIN_VALUE; for (int i = 0; i < val.length; i++) {    if (val[i] < min)       min ... Read More

Implicit Initialization of Variables with 0 or 1 in C

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

288 Views

We know that we need to declare variables before using it in our code. However, we variables can be assigned with 0 or 1 without declaration. In the following example we can see this.Example#include #include x, y, array[3]; // implicit initialization of some variables int main(i) {    //The argument i will hold 1    int index;    printf("x = %d, y = %d", x, y);    for(index = 0; index < 3; index++)       printf("Array[%d] = %d", i, array[i]);       printf("The value of i : %d", i); }Outputx = 0, y = 0 ... Read More

Transfer the Status of Switches in Assembly Program

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

486 Views

In this program we will see how to transfer the switch values from one port to another using 8085 and 8255 chip.Problem Statement:Write 8085 Assembly language program for interfacing between 8085 and 8255. Here eight switches are connected at port A. Transfer the status of these switches into port B. In port B the LEDs are connected.Discussion:The task is very simple. At first we have to setup the control word register of 8255 chip. After that we will take the input from port A, and send it to port B.The control word register is looks like this. It is holding ... Read More

Use Changes in Android SQLite

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

384 Views

Before getting into an example, we should know what sqlite data base in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built-in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrate about How to use changes () in Android sqlite.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to ... Read More

Use getProperty Action in JSP

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

1K+ Views

The getProperty action is used to retrieve the value of a given property and converts it to a string, and finally inserts it into the output.The getProperty action has only two attributes, both of which are required. The syntax of the getProperty action is as follows − ... Following table lists out the required attributes associated with the getProperty action −Sr.No.Attribute & Description1nameThe name of the Bean that has a property to be retrieved. The Bean must have been previously defined.2propertyThe property attribute is the name of the Bean property to be retrieved.ExampleLet us define a test bean that will ... Read More

Find First Non-Repeating Character in a String in Android

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

182 Views

This example demonstrate about How to find its first non-repeating character in a given string in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     In the above code, we have taken text view to show first non-repeating character.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.widget.TextView; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; ... Read More

Set Octet Value in Java Tuples

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

162 Views

To set Octet value in Java, you need to use the setAtX() method. Here, X is the index wherein you need to set the value i.e. to set value at index 1, use the setAt1() and value as a parameter.Let us first see what we need to work with JavaTuples. To work with Octet class in JavaTuples, you need to import the following package −import org.javatuples.Octet;Note − Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> Add External Jars and upload the downloaded JavaTuples ... Read More

Find Duplicate Documents in MongoDB by Key Field

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

399 Views

Use the aggregate framework to find all duplicate documents in a MongoDB collection by a key field.To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.findDuplicateByKeyDemo.insertOne({"StudentId":1, "StudentName":"John"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c7f5b168d10a061296a3c3a") } > db.findDuplicateByKeyDemo.insertOne({"StudentId":2, "StudentName":"Carol"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c7f5b1f8d10a061296a3c3b") } > db.findDuplicateByKeyDemo.insertOne({"StudentId":3, "StudentName":"Carol"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c7f5b248d10a061296a3c3c") } > db.findDuplicateByKeyDemo.insertOne({"StudentId":4, "StudentName":"John"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c7f5b2d8d10a061296a3c3d") } > db.findDuplicateByKeyDemo.insertOne({"StudentId":5, "StudentName":"Sam"}); {    "acknowledged" : true, ... Read More

Advertisements