Global Memory Management in C++: Stack or Heap

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

2K+ Views

Stack and heap are used to store variables during the execution of the program and it also get destroyed.Global data structures or global variables are not consumed by stack or heap. They basically allocated in a fixed memory block, which remains unchanged.int a[10]; // located in a fixed memory block int main() {    int main() {       float *ptr = (int *)malloc(sizeof(float)10.0)); //use heap.    } }

Send Data Between Activities in Android Without Intent

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

3K+ Views

This example demonstrate about How to send data from one activity to another in Android without intent.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.         Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.EditText; public class MainActivity extends AppCompatActivity {    private static String value;    public static String getValue() {       return value; ... Read More

Compare BigDecimal movePointRight and scaleByPowerOfTen in Java

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

309 Views

The java.math.BigDecimal.movePointRight(int n) returns a BigDecimal which is equivalent to this one with the decimal point moved n places to the right. If n is non-negative, the call merely subtracts n from the scale.The java.math.BigDecimal.scaleByPowerOfTen(int n) returns a BigDecimal whose numerical value is equal to (this * 10n). The scale of the result is (this.scale() - n).The following is an example displaying the usage of both −Example Live Demoimport java.math.BigDecimal; public class Demo {    public static void main(String... args) {       long base = 3676;       int scale = 5;       BigDecimal d = ... Read More

Add Separator to Numbers Using MySQL Views

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

188 Views

Let us first create a table −mysql> create table DemoTable (    StudentId int ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(343898456); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values(222333444); Query OK, 1 row affected (0.22 sec)Following is the query to display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+-----------+ | StudentId | +-----------+ | 343898456 | | 222333444 | +-----------+ 2 rows in set (0.00 sec)Here is the query to create view ... Read More

Generation of OBJ File Using a Cross Assembler

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

444 Views

Generation of .OBJ file by using a cross-assembler:The file assembly language program file, e.g. MULT.ASM which is created by using an editor is simply a text file. We cannot execute this file directly. At first we have to assemble the file, and then we have to link it. The step of assembly the translation of the program of assembly language to machine code requires the generation of a .OBJ file.We have used some examples in the text of ‘2500 A.D i.e. the 8085 cross-assembler of version 4.01.In the prompt mode the translation is:We type ‘X8085’ just for performing the translation ... Read More

Status Check of Data Transfer in 8085

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

512 Views

Status check data transfer process is a much more complex process than simple data transfer. We use this method is used when there is lack of accurate knowledge of the Input Output device consisting of the timing characteristics. Status information is received by the processor regarding the readiness of the Input Output device for performing the data transfer. Generally, the processor is involved in the checking of the loop for the device to get ready. The device releases from the loop when the device is ready for use for the execution of the IN or OUT instruction which depends on ... Read More

Read Image File in External Storage with Runtime Permission in Android

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

1K+ Views

This example demonstrates How to read an image file in external storage with runtime permission 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 image view and button. When user click on button, it will take data from external storage and append the data to Image view.Step 3 − Add the following code to src/MainActivity.javapackage com.example.andy.myapplication; import android.content.pm.PackageManager; ... Read More

Check If a Stored Procedure Exists in MySQL

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

896 Views

Let us first create a stored procedure −mysql> DELIMITER // mysql> CREATE PROCEDURE ExtenddatesWithMonthdemo(IN date1 datetime, IN NumberOfMonth int )    -> BEGIN    -> SELECT DATE_ADD(date1, INTERVAL NumberOfMonth MONTH) AS ExtendDate;    -> END;    -> // Query OK, 0 rows affected (0.20 sec) mysql> DELIMITER ;Now you check whether the stored procedure exists with the help SHOW CREATE command.The query is as follows −mysql> SHOW CREATE PROCEDURE ExtenddatesWithMonthdemo; The following is the output displaying the details of the stored procedure we created above: +--------------------------+--------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+--------------------+ | Procedure                | sql_mode ... Read More

Prepared Statements in JDBC: Why They Are Faster

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

620 Views

While executing statements using Statement object, especially insert statements, each time a query is executed the whole statement is compiled and executed again and again where, the only difference among these statements is the values of the statements.Whereas, prepared statement is a precompiled statement i.e. the query is compiled and stored in the database, using place holders (?) instead of values and values to these place holders are supplied later.Thus, avoiding unnecessary compilation and execution of the statement again and again.ExampleSuppose, we have a table named Dataset in the database with the columns mobile_brand and unit_sale, if we want to ... Read More

Use indexOf in Android TextView

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

556 Views

This example demonstrate about How to use indexOf () in Android textview.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 name as Edit text, when user click on button it will take data and returns index of “sai”.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; ... Read More

Advertisements