C++ Program to Implement Stack

Nitya Raut
Updated on 30-Jul-2019 22:30:25
In this program we will see how to implement stack using C++. A stack is an abstract data structure that contains a collection of elements. Stack implements the LIFO mechanism i.e. the element that is pushed at the end is popped out first. Some of the principle operations in the stack are −Push - This adds a data value to the top of the stack.Pop - This removes the data value on top of the stackPeek - This returns the top data value of the stackA program that implements a stack using array is given as follows.Input: Push elements 11, ... Read More

How to fasten MySQL inserts?

George John
Updated on 30-Jul-2019 22:30:25
You can speed the MySQL insert when you are inserting multiple records at the same time with the help of the following syntaxSTART TRANSACTION insert into insertDemo(yourColumnName1, yourColumnName2, ...N) values(yourValue1, yourValue2, ....N), (yourValue1, yourValue2, ....N), .......N commitLet us first create a demo tablemysql> create table insertDemo    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentName varchar(20),    -> StudentAge int    -> ); Query OK, 0 rows affected (0.72 sec)Insert multiple records at the same time. The query is as follows −mysql> START TRANSACTION; Query OK, 0 rows affected (0.00 sec) mysql> insert into ... Read More

How to convert std::string to LPCWSTR in C++?

Krantik Chavan
Updated on 30-Jul-2019 22:30:25
In this section we will see how to convert C++ wide string (std::wstring) to LPCWSTR. The LPCWSTR is the (Long Pointer to Constant Wide STRing). It is basically the string with wide characters. So by converting wide string to wide character array we can get LPCWSTR. This LPCWSTR is Microsoft defined. So to use them we have to include Windows.h header file into our program.To convert std::wstring to wide character array type string, we can use the function called c_str() to make it C like string and point to wide character string.Example Code#include #include using namespace std; main(){    wstring ... Read More

How to dismiss the dialog with click on outside of the dialog?

Nitya Raut
Updated on 30-Jul-2019 22:30:25
This example demonstrate about how to dismiss the dialog with click on outside of the dialogStep 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.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.annotation.TargetApi; import android.content.DialogInterface; import android.os.Build; import android.os.Bundle; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    TextView text;    @TargetApi(Build.VERSION_CODES.LOLLIPOP) ... Read More

Java Program to get maximum value with Comparator

Samual Sam
Updated on 30-Jul-2019 22:30:25
First, declare an integer array and add some elements −Integer arr[] = { 40, 20, 30, 10, 90, 60, 700 };Now, convert the above array to List −List list = Arrays.asList(arr);Now, use Comparator and the reverseOrder() method. Using min() will eventually give you the minimum value, but with reverseOrder(), it reverses the result −Comparator comp = Collections.reverseOrder(); System.out.println("Maximum element = "+Collections.min(list, comp));Example Live Demoimport java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; public class Demo {    @SuppressWarnings("unchecked")    public static void main(String args[]) {       Integer arr[] = { 40, 20, 30, 10, 90, 60, 70 };     ... Read More

wcspbrk() function in C/C++

Smita Kapse
Updated on 30-Jul-2019 22:30:25
The wcspbrk() function is a built in function of C or C++. It searches for a set of wide characters present in a wide string in another wide string. This function is present into cwhar header file.This function takes two arguments. The first argument is destination, and the second argument is the source. As destination we have to pass null terminated wide strings to be searched. As source, we have to pass null terminated wide string, that is containing the characters that will be searched.This function returns two values. If one or more than one wide character is present, this ... Read More

Inplace vs Standard Operators in Python

Chandu yadav
Updated on 30-Jul-2019 22:30:25
Inplace Operator in PythonInplace operation is an operation which directly changes the content of a given linear algebra or vector or metrices without making a copy. Now the operators, which helps to do this kind of operation is called in-place operator.Let’s understand it with an a simple example -a=9 a += 2 print(a)output11Above the += tie input operator. Here first, a add 2 with that a value is updated the previous value.Above principle applies to other operators also. Common in place operators are -+=-=*=/=%=Above principle applies to other types apart from numbers, for example -language = "Python" language +="3" print(language)OutputPython3Above ... Read More

8085 Program to Subtract two multi-Byte numbers

Ankith Reddy
Updated on 30-Jul-2019 22:30:25
Now let us see a program of Intel 8085 Microprocessor. This program is mainly for subtracting multi Byte numbers.Problem Statement:Write 8085 Assembly language program to add two multi-Byte numbers.Discussion:We are using 3-Byte numbers. The numbers are stored into the memory at location 8001H and 8004H. One additional information is stored at location 8000H. In this place we are storing the Byte count. The result is stored at location 8050H.We are taking the address of first operand block address into DE register pair, and the second operand block address into HL pair. The BC register pair is storing the destination address ... Read More

8085 program to find square of a 8 bit number

Chandu yadav
Updated on 30-Jul-2019 22:30:25
In this program, we will see how to find the square of an 8-bit number.Problem StatementWrite 8085 Assembly language program to find the square of a number The number is stored at location 8000H, store the result at 8050H.DiscussionIn 8085, we cannot perform the multiplication operation directly. We are performing the multiplication by using repetitive addition. To get square of a number, we have to multiply the number with itself.InputAddressData……80000C……Flow Diagram ProgramAddressHEX CodesLabelsMnemonicsCommentsF00021, 00, 80 LXI H, 8000HLoad the number from 8000HF003AF XRA AClear accumulatorF00446 MOV B, MLoad data from memory to BF00586LOOPADD MAdd memory byte with AF00605 DCR BDecrease B by 1F007C2, 05, F0 JNZ ... Read More

C++ Program to Perform Searching Using Self-Organizing Lists

George John
Updated on 30-Jul-2019 22:30:25
Self-Organizing list basically updates the list of given range of items on the basis of last searched item. In this method, the sequential searching approach is used. This algorithm shifts the more important data to the beginning of the list. The time complexity of this search technique is O(n).AlgorithmBegin    Function FibonacciSearch().    Calculate the mid value using ‘start+fib[index-2]’ expression.    If the chosen item is equal to the value at mid index, print result and return to main.    If it is lesser than the value at mid index, proceed with the left sub-array.    If it is more ... Read More
Advertisements