Smita Kapse has Published 558 Articles

How to close a Android notification after the user is clicking on it?

Smita Kapse

Smita Kapse

Updated on 30-Jul-2019 22:30:26

126 Views

This example demonstrate about How to close a Android notification after the user is clicking on itStep 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. ... Read More

What is the use of `%p` in printf in C?

Smita Kapse

Smita Kapse

Updated on 30-Jul-2019 22:30:26

10K+ Views

In C we have seen different format specifiers. Here we will see another format specifier called %p. This is used to print the pointer type data. Let us see the example to get a better idea.Example#include main() {    int x = 50;    int *ptr = &x;    printf("The ... Read More

C++ Program to Perform Finite State Automaton based Search

Smita Kapse

Smita Kapse

Updated on 30-Jul-2019 22:30:26

613 Views

This is a C++ program to perform finite state automaton based search. An automaton with a finite number of states is called a Finite Automaton. Here, a text is given text[0 … t-1] and a pattern p[0 ... p-1] is also given. We have to find the pattern in the ... Read More

How to clear an Android notification after a few seconds?

Smita Kapse

Smita Kapse

Updated on 30-Jul-2019 22:30:26

526 Views

This example demonstrate about How to clear an Android notification after a few seconds.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 ... Read More

How to implement MongoDB $or operator

Smita Kapse

Smita Kapse

Updated on 30-Jul-2019 22:30:26

116 Views

Evaluate one or more expressions using the $or operator in MongoDB. Following is the syntax −db.yourCollectionName.find({ $or: [{ "yourFieldName": yourValue1 }, { "yourFieldName": yourValue2} ] } ).pretty();Let us first create a collection with documents −> db.orOperatorDemo.insertOne({"StudentNames":["John", "Carol", "Sam"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd6b80a6d78f205348bc61b") } > db.orOperatorDemo.insertOne({"StudentNames":["Robert", ... Read More

C++ Program to Encode a Message Using Playfair Cipher

Smita Kapse

Smita Kapse

Updated on 30-Jul-2019 22:30:26

4K+ Views

In this scheme, pairs of letters are encrypted, instead of single letters as in the case of simple substitution cipher.In playfair cipher, initially a key table is created. The key table is a 5×5 grid of alphabets that acts as the key for encrypting the plaintext. Each of the 25 ... Read More

How to create a JSlider that snap to the closest tick mark in Java?

Smita Kapse

Smita Kapse

Updated on 30-Jul-2019 22:30:26

260 Views

At first, let us first create a slider in Java −JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 40); slider.setMinorTickSpacing(10); slider.setMajorTickSpacing(20); slider.setPaintTicks(true); slider.setPaintLabels(true);Now, we will snap closest tick mark value as shown below −slider.setSnapToTicks(true);The following is an example to create a JSlider that snap to the closest tick mark −Examplepackage my; ... Read More

Function pointer to member function in C++

Smita Kapse

Smita Kapse

Updated on 30-Jul-2019 22:30:26

12K+ Views

In C++ , function pointers when dealing with member functions of classes or structs, it is invoked using an object pointer or a this call. We can only call members of that class (or derivatives) using a pointer of that type as they are type safe.Example Live Demo#include using namespace ... Read More

C++ Program to Implement the Hill Cypher

Smita Kapse

Smita Kapse

Updated on 30-Jul-2019 22:30:26

6K+ Views

Based on linear algebra Hill cipher is a polygraphic substitution cipher in cryptography.To encrypt message: The key string and message string are represented as matrix form. They are multiplied then, against modulo 26. The key matrix should have inverse to decrypt the message.To decrypt message: The encrypted message is multiplied ... Read More

C++ Program to Implement Kadane’s Algorithm

Smita Kapse

Smita Kapse

Updated on 30-Jul-2019 22:30:26

1K+ Views

Kadane’s algorithm is used to find out the maximum subarray sum from an array of integers. Here we shall discuss a C++ program to implement this algorithm.AlgorithmBegin Function kadanes(int array[], int length):    Initialize    highestMax = 0    currentElementMax = 0    for i = 0 to length-1   ... Read More

Advertisements