In this program we will see how to add first n natural numbers.Problem StatementWrite 8085 Assembly language program to add first N natural numbers. The value of N is provided.DiscussionWe are getting the value of N from memory location 8000H. We are using the number N as count variable, in each step we are calculating (A + Count) value, and store them into A. After adding them, the count value is decreased, thus the total series is completed.If the number is 23H(35D), then the sum will be (35*36)/2 = 630 (276H)InputAddressData......800023......Flow DiagramProgramAddressHEX CodesLabelsMnemonicsCommentsF00021, 00, 80LXI H, 8000HPoint to get the ... Read More
Before getting into example, we should know what is Recycler view in android. Recycler view is more advanced version of list view and it works based on View holder design pattern. Using recycler view we can show grids and list of items .This example demonstrate about how to Scroll top in RecyclerView with LinearLayoutManager by creating a beautiful student records app that displays student name with age .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 − Open build.gradle and add Recycler ... Read More
To get the set of values in IdentityHashMap, use the values() method.First, set the IdentityHashMapMap m = new IdentityHashMap(); m.put("1", 100); m.put("2", 200); m.put("3", 300); m.put("4", 150); m.put("5", 110); m.put("6", 50); m.put("7", 90); m.put("8", 250); m.put("9", 350); m.put("10", 450);Now, retrieve the set of valuesm.values()The following is an example to get the set of values in IdentityHashMap using values() methodExample Live Demoimport java.util.*; public class Demo { public static void main(String[] args) { Map m = newIdentityHashMap(); m.put("1", 100); m.put("2", 200); ... Read More
In this program we will see how to count number of 1's in an 8-bit number.Problem StatementWrite 8085 Assembly language program to count number of 1s in 8-bit number stored atlocation 8000H.DiscussionIn this program we areusing the rotate operation to count the number of 1's. As there are8 different bits in 8-bit number, then we are rotating the numbereight times. we can use RRC or RLC. Here we have used the RRCinstruction. This instruction sends the LSb to MSb also to carryflag. So after each iteration we can check the carry status to getthe count of 1s.If the number is ... Read More
Before getting into example, we should know what is Recycler view in android. Recycler view is more advanced version of list view and it works based on View holder design pattern. Using recycler view we can show grids and list of items.This example demonstrate about how to update Recycler View adapter by creating a beautiful student records app that displays student name with age.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 − Open build.gradle and add Recycler view & Card view ... Read More
Here we are trying to do two tasks at a time, one in the foreground and the other in the background. We’ll write something in the file in the background and of a user input number, will find if it’s an odd or even number.Doing multiple tasks in one program in python is possible through multithreading in Live Demoimport threading import time class AsyncWrite(threading.Thread): def __init__(self, text, out): threading.Thread.__init__(self) self.text = text self.out = out def run(self): f = open(self.out, "a") f.write(self.text + '') ... Read More
As you know if you use LIMIT 0 in MySQL SELECT statement, it returns an empty set.The LIMIT can be used when you want a specified number of rows from a result rather than the entire rows. If you use any MySQL API, then the job of LIMIT is to acquire the type of result columns.LIMIT 0 can be used to check the validity of a query. For more details use the following link −https://dev.mysql.com/doc/refman/8.0/en/limit-optimization.htmlHere is the demo of LIMIT 0. The query to create a table is as follows −mysql> create table Limit0Demo -> ( -> Id ... Read More
To display the path separator, use the Properties class and import the following package −import java.util.Properties;Use the getProperties() method first and create an object −Properties p = System.getProperties();Now, set the key for path separator −p.getProperty("path.separator")The following is an example −Example Live Demoimport java.util.Properties; public class Demo { public static void main(String[] args) { Properties p = System.getProperties(); System.out.println("Separator is "+p.getProperty("path.separator")); } }OutputSeparator is :
Set width in output as shown below. Here, %10 sets a 10 character fieldSystem.out.printf("d1 = %10.2f d2 = %8g", d1, d2);Above, the value after the decimal is for decimal places i.e. 5.3 is for 3 decimal places −System.out.printf("d1 = %5.3f d2 = %2.5f", d1, d2);The following is an example −Example Live Demopublic class Demo { public static void main(String[] args) throws Exception { double d1 = 399.8877; double d2 = 298.87690; System.out.printf("d1 = %10.2f d2 = %8g", d1, d2); System.out.printf("d1 = %5.3f d2 = %2.5f", d1, d2); } }Outputd1 = 399.89 d2 = 298.877 d1 = 399.888 d2 = 298.87690
To get the size of IdentityHashMap, use the size() method. It returns the count of elements in the IdentityHashMap.Let us first create a IdentityHashMap and add some elements to itMap m = new IdentityHashMap(); m.put("1", 100); m.put("2", 200); m.put("3", 300); m.put("4", 150); m.put("5", 110); m.put("6", 50); m.put("7", 90); m.put("8", 250); m.put("9", 350); m.put("10", 450);Now, get the sizem.size();The following is an example to get the size of the IdentityHashMapExample Live Demoimport java.util.*; public class Demo { public static void main(String[] args) { Map m = newIdentityHashMap(); m.put("1", ... Read More