How to use clock() function in C++

Anvi Jain
Updated on 30-Jul-2019 22:30:26
Here we will see how to use the clock() in C++. This clock() is present in the time.h or ctime header file. Here we will find the elapsed time of a process using this clock() functionTo get the elapsed time, we can get the time using clock() at the beginning, and at the end of the taks, then subtract the values to get the differences. After that we will divide the difference by CLOCK_PER_SEC (Number of clock ticks per second) to get the processor time.Example#include #include using namespace std; void take_enter() {    cout

C++ Program to Implement Caesar Cypher

Anvi Jain
Updated on 30-Jul-2019 22:30:26
It is a mono-alphabetic cipher wherein each letter of the plaintext is substituted by another letter to form the ciphertext. It is a simplest form of substitution cipher scheme.This cryptosystem is generally referred to as the Shift Cipher. The concept is to replace each alphabet by another alphabet which is ‘shifted’ by some fixed number between 0 and 25.For this type of scheme, both sender and receiver agree on a ‘secret shift number’ for shifting the alphabet. This number which is between 0 and 25 becomes the key of encryption.The name ‘Caesar Cipher’ is occasionally used to describe the Shift ... Read More

How to remove the notification after the particular time in android?

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26
This example demonstrate about How to remove the notification after the particular time in androidStep 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 app.tutorialspoint.com.notifyme ; import android.app.NotificationChannel ; import android.app.NotificationManager ; import android.app.PendingIntent ; import android.content.Context ; import android.content.Intent ; import android.os.Handler ; import android.support.v4.app.NotificationCompat ; import android.support.v7.app.AppCompatActivity ; import android.os.Bundle ; import android.view.View ; import android.widget.Button ; public class MainActivity extends AppCompatActivity ... Read More

Undefined Behaviour in C and C++

Arjun Thakur
Updated on 30-Jul-2019 22:30:26
Here we will see some C and C++ Codes. and try to guess the results. The codes will generate some runtime errors.1. The Divide By Zero error is undefined.Example Code#include using namespace std; int main() {    int x = 10, y = 0;    int z = x / y;    cout

How to change the maximum value of a JSlider in Java?

Anvi Jain
Updated on 30-Jul-2019 22:30:26
To change the maximum value of a slider in Java, use the setMaximum() method wherein set the maximum value.Let’s say the following is our slider in Java −JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 55); slider.setMinorTickSpacing(10); slider.setMajorTickSpacing(25); slider.setPaintTicks(true); slider.setPaintLabels(true);Now, set the maximum value −slider.setMaximum(150);The following is an example to change the maximum value of a slidier −Examplepackage my; import java.awt.Color; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.WindowConstants; public class SwingDemo {    public static void main(String[] args) {       JFrame frame = new JFrame("Frame with Slider");       JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, ... Read More

How to implement MongoDB $or operator

Smita Kapse
Updated on 30-Jul-2019 22:30:26
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", "Chris", "David"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd6b8266d78f205348bc61c") } > db.orOperatorDemo.insertOne({"StudentNames":["John"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd6b8346d78f205348bc61d") }Following is the query to display all documents from a collection with the help of find() method −> db.orOperatorDemo.find().pretty();This will produce the following output −{    "_id" ... Read More

HTML <area> alt Attribute

Chandu yadav
Updated on 30-Jul-2019 22:30:26
The alt attribute of element is used to set an alternate text for an area. This alternate text i.e. alt is visible when the image isn’t displayed for reasons like internet, loading issues, errors, etc.Following is the syntax −Here, text is the alt text to be set.Let us now see an example to implement the alt attribute of the element −Example Live Demo Learning Learn these technologies with ease.... OutputIn the above example, we have set the map on the following ... Read More

How To Do Math With Lists in python ?

Sri
Sri
Updated on 30-Jul-2019 22:30:26
We  not only use lists to store a collection of values, but we also use it to perform some mathematical calculations or operations to do.Example 1import math data = 21.6 print('The floor of 21.6 is:', math.floor(data))OutputThe floor of 21.6 is: 21How To Calculate the Weighted Average of a ListExample 2cost = [0.424, 0.4221, 0.4185, 0.4132, 0.413] cases = [10, 20, 30, 40, 50] cost = [23, 10, 5, 32, 41] weight= [10, 20, 30, 40, 50] for i in range(len(cost)): cost[c] = (cost[i] * weight[i] / sum(weight)) cost = sum(cost) print(cost)Output72.84444444444445Example 3import math degree = 180 radian = math.radians(degree) ... Read More

How to add shadow on text swift?

Sharon Christine
Updated on 30-Jul-2019 22:30:26
If you’re developing a game or a kids application or an application where you want to make attractive user interface you must know how to add shadow on text. This will not only makes the text attractive but also it will also enhance the user experience.Here we will see how we can add shadow on text.Step 1 − Open Xcode → New Project → Single View Application → Let’s name it “ShadowText”Step 2 − Add label in Main.storyboard and create @IBOutlet of the label and name it lblHelloWorld.Step 3 − Add the below code in your ViewController.swift, add the complete ... Read More

HTML DOM li value Property

AmitDiwan
Updated on 30-Jul-2019 22:30:26
The Li value property returns/sets the value of the value attribute of a element.SyntaxFollowing is the syntax −Returning value of the value attributeliObject.valueValue of the attribute value setliObject.value = ‘string’Let us see an example for Li value property −Example Live Demo HTML DOM value    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    }    ol{       width: 30%;   ... Read More
Advertisements