Add Only Odd Numbers from a Number Array

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

1K+ Views

Odd number summation using JavaScript. Live DemoExample var tot = 0; var a = [1,45,78,9,78,40,67,76]; for(var i = 0; i

Add JRadioButtonMenuItem in Java

Chandu yadav
Updated on 30-Jul-2019 22:30:26

224 Views

Let’s say we have a menu and within that we need to set the JRadioButtonMenuItem. Here’s the Menu −JMenu editMenu = new JMenu("Edit"); editMenu.setMnemonic(KeyEvent.VK_E); menuBar.add(editMenu);Now, set the editMenu and add it to the MenuBar −JMenu editMenu = new JMenu("Edit"); editMenu.setMnemonic(KeyEvent.VK_E); menuBar.add(editMenu);Now, create Options Menu and add it to the editMenu −JMenu optionsMenu = new JMenu("Options"); optionsMenu.setMnemonic(KeyEvent.VK_O); editMenu.add(optionsMenu);Now, set the JRadioButtonMenuItem and add it to the editMenu created above −ButtonGroup group = new ButtonGroup(); JRadioButtonMenuItem radioMenuItem = new JRadioButtonMenuItem("SmartInsertMode", true); radioMenuItem.setMnemonic(KeyEvent.VK_I); optionsMenu.add(radioMenuItem); group.add(radioMenuItem); JRadioButtonMenuItem radioMenuItem2 = new JRadioButtonMenuItem("SmartDeleteMode"); radioMenuItem.setMnemonic(KeyEvent.VK_D); optionsMenu.add(radioMenuItem2); group.add(radioMenuItem2);The following is an example add JRadioButtonMenuItem in Java −Examplepackage my; ... Read More

Sort By Value with MySQL ORDER BY

Chandu yadav
Updated on 30-Jul-2019 22:30:26

234 Views

For this, use the ORDER BY clause. Let us first create a table −mysql> create table DemoTable    (    StudentId int    ); Query OK, 0 rows affected (0.59 sec)Now you can insert some records in the table using insert command −mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(60); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(70); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(45); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable values(55); Query OK, 1 row affected ... Read More

Applications of Pointers in C/C++

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

1K+ Views

To access array elementsWe can access array elements by using pointers.In CExample Live Demo#include int main() {    int a[] = { 60, 70, 20, 40 };    printf("%d", *(a + 1));    return 0; }Output70In C++Example Live Demo#include using namespace std; int main() {    int a[] = { 60, 70, 20, 40 };    cout

Make Button Corners Round in iOS

Sharon Christine
Updated on 30-Jul-2019 22:30:26

2K+ Views

You might come across a scenarios where you received a UI where the buttons are rounded, and you might wonder how to do that? So here we will see how to make corners of a button round.We will be seeing both the ways to make the button rounded, one using Storyboard and another programmatically.Let’s get started! First we will make the corners of button rounded using Storyboard.Step 1 − Open Xcode → New Projecr → Single View Application → Let’s name it “RoundedButton”Step 2 − Open Main.storyboard and add a button as show belowStep 3 − Now select the button ... Read More

HTML DOM Input Month Required Property

Sharon Christine
Updated on 30-Jul-2019 22:30:26

127 Views

The HTML DOM input month required property returns and modify whether the input month field must be filled out before submitting the form.SyntaxFollowing is the syntax −1. Returning requiredobject.required2. Modifying requiredobject.required = true | falseExampleLet us see an example of HTML DOM input month required property − Live Demo    html{       height:100%;    }    body{       text-align:center;       color:#fff;       background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%)       center/cover no-repeat;       height:100%;    }    p{       font-weight:700;       font-size:1.1rem;   ... Read More

C++ Program for GCD of More Than Two or Array Numbers

Arnab Chakraborty
Updated on 30-Jul-2019 22:30:26

200 Views

Here we will see how we can get the gcd of more than two numbers. Finding gcd of two numbers are easy. When we want to find gcd of more than two numbers, we have to follow the associativity rule of gcd. For example, if we want to find gcd of {w, x, y, z}, then it will be {gcd(w, x), y, z}, then {gcd(gcd(w, x), y), z}, and finally {gcd(gcd(gcd(w, x), y), z)}. Using array it can be done very easily.Algorithmgcd(a, b)begin    if a is 0, then       return b    end if    return gcd(b ... Read More

Generate Random Numbers Using C++11 Random Library

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

2K+ Views

In C++11, we can get the random library to generate random numbers. Here we have used random_device once to seed the random number generator object called mt. This random_device is slower than the mt19937, but we do not need to seed it. It requests for random data to the operating system.Example #include #include using namespace std; int main() {    random_device rd;    mt19937 mt(rd());    uniform_real_distribution dist(20.0, 22.0); //range is 20 to 22    for (int i=0; i> dist(mt) >> endl; }Output21.5311 21.7195 21.0961 21.9679 21.197 21.2989 20.6333 20.441 20.7124 20.2654 21.1877 20.4824 20.0575 20.9432 21.222 21.162 21.1029 20.2253 21.5669 20.3357

Pre-select JComboBox Item by Index in Java

Krantik Chavan
Updated on 30-Jul-2019 22:30:26

1K+ Views

The following is an example to pre-select JComboBox item by index in Java. Here, we have selected the 3rd item by default i.e. whenever the Swing program will run, the third item would be visible instead of the 1st.Exampleimport java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextArea; public class SwingDemo {    public static void main(String[] args) {       JPanel panel = new JPanel(new BorderLayout());       String[] strArr = new String[] { "Laptop", "Mobile", "Desktop", "Tablet" };       JComboBox comboBox = new JComboBox(strArr);       panel.add(comboBox, ... Read More

Close Android Notification After User Clicks

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

224 Views

This example demonstrate about How to close a Android notification after the user is clicking on itStep 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.     Step 3 − Add the following code to src/MainActivity.javapackage app.tutorialspoint.com.notifyme ; import android.app.NotificationChannel ; import android.app.NotificationManager ; import android.app.PendingIntent ; import android.content.Context ; import android.content.Intent ; import android.support.v4.app.NotificationCompat ; import android.support.v7.app.AppCompatActivity ; import android.os.Bundle ; import android.view.View ; import android.widget.Button ; public class MainActivity extends AppCompatActivity { ... Read More

Advertisements