Print Numbers from 1 to 100 Without Using Loop

George John
Updated on 30-Jul-2019 22:30:25

762 Views

Here we will see how to write a C program that can print numbers from 1 to 100 without using any kind of loops.This problem can be solved using the recursion. We will create a function that will be called recursively. As we know that a recursive function has basically two sections. The base case and the recursive call and other operation. In this function the base case is the argument n is greater than 1. Until it reaches 1, the function will be called recursively. Now at the end it will print the value of n. Thus the entire ... Read More

Order By Inside of Group By in MySQL: Is It Possible?

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

811 Views

Instead of using ORDER BY inside GROUP BY, you can use the MAX() aggregate function.The syntax is as follows −SELECT yourNameColumnName, MAX(yourRankColumnName) FROM yourTableName GROUP BY yourNameColumnName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table MaxDemo    -> (    -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> UserName varchar(20),    -> UserRank int    -> ); Query OK, 0 rows affected (0.77 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into MaxDemo(UserName, UserRank) values('Larry', 2); Query ... Read More

What is Info Attribute in JSP

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

360 Views

The info attribute lets you provide a description of the JSP. The following is a coding example −

Add Action Icon in Android

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

452 Views

This example demonstrates how to add an action icon 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 action bar icon status.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.annotation.SuppressLint; import android.app.ActivityManager; import android.app.admin.DevicePolicyManager; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; import android.view.View; import android.widget.TextView; ... Read More

LocalTime equals Method in Java

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

478 Views

The equality of two LocalTime objects can be determined using the equals() method in the LocalTime class in Java. This method requires a single parameter i.e. the LocalTime object to be compared. Also it returns true if both the LocalTime objects are equal and false otherwise.A program that demonstrates this is given as followsExample Live Demoimport java.time.*; public class Main {    public static void main(String[] args) {       LocalTime lt1 = LocalTime.parse("23:15:30");       LocalTime lt2 = LocalTime.parse("23:15:30");       System.out.println("The LocalTime lt1 is: " + lt1);       System.out.println("The LocalTime lt2 is: " + ... Read More

Equals Method of AbstractSequentialList in Java

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

117 Views

The equals() method is inherited from the AbstractList class in Java. It is used to check the object for equality with this list. It returns TRUE if the object is equal to this list, else FALSE is returned.The syntax is as follows −public boolean equals(Object o)Here, o is the object to be compared for equality with this list.To work with the AbstractSequentialList class in Java, you need to import the following packageimport java.util.AbstractSequentialList;The following is an example to implement AbstractSequentialList equals() method in JavaExample Live Demoimport java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo {    public static void main(String[] args) { ... Read More

Compare Only Day and Month with Date Field in MySQL

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

3K+ Views

You can compare only day and month with date field in MySQL with the help of DATE_FORMAT().The syntax is as followsselect *from yourTableName WHERE DATE_FORMAT(yourColumnName, '%m-%d') = DATE_FORMAT('yourValue', '%m-%d') and yourCondition;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table compareDayAndMonthDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> compareDayAndTime date    -> ); Query OK, 0 rows affected (0.49 sec)Insert some records in the table using insert command.The query is as followsmysql> insert into compareDayAndMonthDemo(compareDayAndTime) values('2014-01-31'); Query OK, 1 row affected (0.20 ... Read More

MongoDB Query by Sub-Field

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

2K+ Views

You can use dot(.) notation to query by subfield. Let us create a collection with a document. The query to create a collection with a document is as follows −> db.queryBySubFieldDemo.insertOne(    ... {       ... "StudentPersonalDetails" : {"StudentName" : "John", "StudentHobby" :"Photography"},       ... "StudentScores" : {"MathScore" : 56}    ... } ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5c92c2995259fcd195499808") } > db.queryBySubFieldDemo.insertOne(    ... {       ... "StudentPersonalDetails" : {"StudentName" : "Chris", "StudentHobby" :"Reading"},       ... "StudentScores" : {"MathScore" : 97}    ... } ... ); { ... Read More

XML Parsing in Python

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

2K+ Views

Python XML parser parser provides one of the easiest ways to read and extract useful information from the XML file. In this short tutorial we are going to see how we can parse XML file, modify and create XML documents using python ElementTree XML API.Python ElementTree API is one of the easiest way to extract, parse and transform XML data.So let’s get started using python XML parser using ElementTree:Example1Creating XML fileFirst we are going to create a new XML file with an element and a sub-element.#Import required library import xml.etree.ElementTree as xml def createXML(filename):    # Start with the ... Read More

Use Handler in Android

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

924 Views

This example demonstrate about How to use handler in androidStep 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.Step 3 − Add the following code to src/MainActivity.java import android.os.Bundle; import android.os.Handler; import android.support.v4.app.FragmentActivity; import android.util.DisplayMetrics; import android.widget.Button; import java.util.Random; import java.util.Timer; import java.util.TimerTask; public class MainActivity extends FragmentActivity {    Handler handler;    @Override    public void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState); ... Read More

Advertisements