Count Numbers with N Digits Consisting of Even Number of 0s in C++

Sunidhi Bansal
Updated on 01-Dec-2020 12:02:25

185 Views

We are given a number N as input. The goal is to find all N digit numbers that have an even number of 0’s as digits. The number also could have preceding zeros like in case of N=3 numbers included will be 001, 002, 003….010….so on.Let us understand with examples.Input − N=4Output − Count of no. with N digits which consists of even number of 0's are − 7047Explanation − All 4 digits numbers would be like −Smallest will be 0000, then 0011, 0012, 0013, 0014…..Highest will be 9900.Input − N=5Output − Count of no. with N digits which consists ... Read More

Count Number of Pairs (A, B) Such That GCD(A, B) is B in C++

Sunidhi Bansal
Updated on 01-Dec-2020 12:01:08

692 Views

We are given an input N. The goal is to find all pairs of A, B such that 1

Use SharedPreferences on Android with Kotlin

Azhar
Updated on 01-Dec-2020 05:19:24

320 Views

This example demonstrates how to use SharedPreferences on Android to store, read and edit values using Kotlin.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.ktimport android.content.SharedPreferences import android.os.Bundle import android.view.View import android.widget.EditText import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var editTextName: EditText    private lateinit ... Read More

Pass Data Between Activities in Android Using Kotlin

Azhar
Updated on 01-Dec-2020 05:14:26

419 Views

This example demonstrates how to pass data between Activities on an Android application using Kotlin.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.ktimport android.content.Intent import android.os.Bundle import android.widget.Button import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    private val myRequestCode = 1    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main) ... Read More

COBOL Host Variable Equivalent for DB2 Data Types

Mandalika
Updated on 01-Dec-2020 05:07:03

1K+ Views

Problem: How will the COBOL-DB2 program behave when there is a mismatch between the host variable and number of columns in the SELECT statement?SolutionIn case there is a mismatch in the number of columns and number of host variables, the query will fail. For example, if we have used the below query in a COBOL-DB2 program which processes the ORDERS DB2 table.ExampleEXEC SQL    SELECT ORDER_ID,       ORDER_AMOUNT,       ORDER_DATE,       ORDER_STATUS    INTO :WS-ORDER-ID,       :WS-ORDER-AMOUNT,       :WS-ORDER-DATE,    FROM ORDERS WHERE ORDER_DATE = ‘2020-09-15’ END-EXECThere is a mismatch ... Read More

Purpose and Usage of FOR UPDATE OF Clause in COBOL DB2 Program

Mandalika
Updated on 01-Dec-2020 05:05:31

5K+ Views

Problem: What is the purpose of the "FOR UPDATE OF" clause in a cursor? What will happen if we fire an UPDATE statement without using this clause in a COBOL-DB2 program?SolutionThe “FOR UPDATE OF” clause is given in the cursor declaration and it is used when we want to update the table. All the columns which need to be updated should be given in the cursor declaration.The “FOR UPDATE OF” clause will place the exclusive lock on all the qualifying rows once the cursor is open. We can also update the table without using “FOR UPDATE CLAUSE” but in that ... Read More

Update Operation on Cursor with Join Between 2 Tables

Mandalika
Updated on 01-Dec-2020 05:04:28

750 Views

Problem: Is it possible to update a CURSOR in which we have used JOIN on 2 tables ORDERS and TRANSACTIONS? Why or why not? How can we proceed to UPDATE any of these tables?SolutionWhenever we use JOIN in a cursor on two or more tables (ORDERS and TRANSACTIONS in this case) a temporary table is generated in the virtual memory. However, since this is a temporary table we can fetch data from this table but it is not possible to update this table.If we want to update any of the tables used in the JOIN then we have to declare ... Read More

Call onDestroy Activity in Android App using Kotlin

Azhar
Updated on 01-Dec-2020 05:03:52

1K+ Views

This example demonstrates how to call OnDestroy Activity in an Android App using Kotlin?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.ktimport android.os.Bundle import android.util.Log import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    private val myTag = "Destroy"    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"   ... Read More

Execution Result of Non-SQL Changes Without Bind in Programs

Mandalika
Updated on 01-Dec-2020 05:03:14

241 Views

Problem: A COBOL-DB2 program is changed to increase the length of a variable from PIC X(5) to PIC X(8). However, there are no changes in the SQL of the program. What will be the result if the program's plan/package is not binded for these changes?SolutionThe variable length change from PIC X(5) to PIC X(8) is not a DB2 change and there are no modifications required for SQL statements in the program. However, still we need to BIND its PLAN/PACKAGE else we will get SQL error code -818 which states that “THE PRECOMPILER-GENERATED TIMESTAMP x IN THE LOAD MODULE IS DIFFERENT ... Read More

Execution Result of DB2 Program Compilation and Binding on Separate Days

Mandalika
Updated on 01-Dec-2020 05:02:19

247 Views

Problem: The DB2 program PROGA was changed and compiled, but it was binded after 3 days. What will happen if we execute this program on the 4th day?SolutionThe pre-compiler inserts the current timestamp in the modified source code and in DBRM. In case of modified source code, this timestamp is passed on to the load module and in case of DBRM the timestamp is passed on to the package. At the time of program execution, the timestamp of load module and package is compared. This comparison takes place to ensure that the correct version of package and load module is ... Read More

Advertisements