Smita Kapse has Published 558 Articles

Catch block and type conversion in C++

Smita Kapse

Smita Kapse

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

102 Views

In this section, we will see how to use the catch block for exception handling and the type conversion in C++.At first, let us see a code, and we will see what will be the output, and how they are generating.Example#include using namespace std; int main() {    try{ ... Read More

Generating random number in a range in C

Smita Kapse

Smita Kapse

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

3K+ Views

Here we will see how to generate random number in given range using C. To solve this problem, we will use the srand() function. The current time will be used to seed the srad() function.This function cannot generate random number in any range, it can generate number between 0 to ... Read More

Implement multiple conditions in MongoDB?

Smita Kapse

Smita Kapse

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

197 Views

Let us first create a collection with documents −> db.multipleConditionDemo.insertOne({"_id":1, "Name":"John"}); { "acknowledged" : true, "insertedId" : 1 } > db.multipleConditionDemo.insertOne({"_id":2, "Name":"Carol"}); { "acknowledged" : true, "insertedId" : 2 } > db.multipleConditionDemo.insertOne({"_id":3, "Name":"Sam"}); { "acknowledged" : true, "insertedId" : 3 } > db.multipleConditionDemo.insertOne({"_id":4, "Name":"David"}); { "acknowledged" : true, "insertedId" : ... Read More

How to create Horizontal Slider in Java?

Smita Kapse

Smita Kapse

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

393 Views

To create Horizontal slider in Java, use the Swing JSlider. Let us first create a frame and a Horizontal slider in it −JFrame frame = new JFrame("Frame with Slider"); JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 70);Now, we will set the values for the slider. Display the ticks −slider.setMinorTickSpacing(5); slider.setMajorTickSpacing(20); ... Read More

C qsort() vs C++ sort()

Smita Kapse

Smita Kapse

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

410 Views

Here we will see what are the differences between qsort() in C, and sort() in C++.The C provides qsort() function, that can be used for sorting an array. The function arguments and syntax is like below.void qsort(void *base, size_t num, size_t size, int (*comparator) (const void*, const void*));This function takes ... Read More

How to use POSIX semaphores in C language

Smita Kapse

Smita Kapse

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

2K+ Views

The semaphore is a concept of process or thread synchronization. Here we will see how to use the semaphores in real programs.In Linux system, we can get the POSIX semaphore library. To use it, we have to include semaphores.h library. We have to compile the code using the following options.gcc ... Read More

How to retrieve a nested object in MongoDB?

Smita Kapse

Smita Kapse

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

870 Views

To retrieve a nested object in MongoDB, use $ operator. Let us first create a collection with documents −> db.queryNestedObject.insertOne( ...    { ...       "StudentName" : "James", ...       "StudentSubjectScore" : [ ...          {"StudentMongoDBScore":98}, ...          {"StudentCScore":92}, ... ... Read More

How to calculate timestamp difference in hours with MongoDB?

Smita Kapse

Smita Kapse

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

792 Views

To calculate timestamp difference, use aggregate framework. Let us first create a collection with documents −> db.timestampDifferenceDemo.insertOne({    "MovieBeginningTime": new ISODate("2019-05-12 10:20:30"),    "MovieEndingTime":new ISODate("2019-05-12 12:30:20") }); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7ba1f6d78f205348bc644") } > db.timestampDifferenceDemo.insertOne({    "MovieBeginningTime": new ISODate("2019-05-12 04:00:00"),    "MovieEndingTime":new ISODate("2019-05-12 07:10:00") }); { ... Read More

Reverse a string in C/C++ using Client Server model

Smita Kapse

Smita Kapse

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

1K+ Views

Here we will see how we can create a system, where we will create one client, and a server, and the client can send one string to the server, and the server will reverse the string, and return back to the client.Here we will use the concept of socket programming. ... Read More

How to schedule local notifications in Android?

Smita Kapse

Smita Kapse

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

2K+ Views

This example demonstrate about How to schedule local notification 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. Step 3 − Add the following ... Read More

Advertisements