Nishtha Thakur has Published 498 Articles

trunc() , truncf() , truncl() in C language

Nishtha Thakur

Nishtha Thakur

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

2K+ Views

Here we will see three functions. These functions are trunc(), truncf() and the truncl(). These functions are used to convert floating point values into truncated form.The trunc() FunctionThis function is used to truncate double type value. And return only the integer part. The syntax is like below.double trunc(double argument)Example#include ... Read More

Variable collection name in MongoDB shell with JavaScript?

Nishtha Thakur

Nishtha Thakur

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

230 Views

Yes, you can set a variable collection name in MongoDB shell using JavaScript. Let us first create a collection with documents −> db.employeeInformation.insertOne({"EmployeeName":"John Smith", "EmployeeAge":24, "EmployeeSalary":450000}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cc6d06baf8e7a4ca6b2ad97") }Following is the query to display all documents from a collection with the help of ... Read More

Foreach in C++ and Java

Nishtha Thakur

Nishtha Thakur

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

167 Views

In C++ and Java, there are another type of loop called foreach loop. This is not present in C. This loop has introduced in C++11 and Java JDK 1.5.0. The advantage of this loop is that, it can access the elements very quickly without performing initialization, testing and increment/decrement. This ... Read More

How do you perform an AND query on an array in MongoDB?

Nishtha Thakur

Nishtha Thakur

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

188 Views

To get the same result like AND in MongoDB, use the $all operator. Let us first create a collection with documents −> db.andQueryDemo.insertOne({"StudentName":"Carol Taylor", "FavouriteSubject":["C", "Java", "MongoDB", "MySQL"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cc73e7a8f9e6ff3eb0ce433") } > db.andQueryDemo.insertOne({"StudentName":"David Miller", "FavouriteSubject":["C++", "Java", "MongoDB", "SQL Server"]}); {    "acknowledged" : ... Read More

How to get tag count in MongoDB query results based on list of names?

Nishtha Thakur

Nishtha Thakur

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

168 Views

You can use $in operator. Let us first create a collection with documents −> db.tagCountDemo.insertOne({"ListOfNames":["John", "Sam", "Carol"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd64b387924bb85b3f48944") } > db.tagCountDemo.insertOne({"ListOfNames":["Bob", "David", "John"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd64b4b7924bb85b3f48945") } > db.tagCountDemo.insertOne({"ListOfNames":["Mike", "Robert", "Chris"]}); {    "acknowledged" : true, ... Read More

How to get this nodes’s parent in a JTree with Java?

Nishtha Thakur

Nishtha Thakur

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

856 Views

Let’s say we want the parent of a node, then use the getParent() method -node3.getFirstChild()You can also get the parent of child node. Here, “nine” is the child node −nine.getParent()The output is as follows displaying this node’s parent on Console −Examplepackage my; import javax.swing.JFrame; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; public class ... Read More

When should we write our own assignment operator in C++?

Nishtha Thakur

Nishtha Thakur

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

460 Views

Here we will see when we need to create own assignment operator in C++. If a class do not have any pointers, then we do not need to create assignment operator and copy constructor. C++ compiler creates copy constructor and assignment operator for each class. If the operators are not ... Read More

8086 program to determine modulus of first array elements corresponding to another array elements

Nishtha Thakur

Nishtha Thakur

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

310 Views

In this program we will see how to perform modulus of the first array corresponding to the next array.Problem StatementWrite 8086 Assembly language program perform modulus of the first array corresponding to the next array.DiscussionIn this example there are two different arrays. The arrays are stored at location 501 onwards ... Read More

Find in a dictionary like structure by value with MongoDB?

Nishtha Thakur

Nishtha Thakur

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

1K+ Views

You can use find() for this. Let us first create a collection with documents −> db.findInDictionaryDemo.insertOne( ...    { ...       "_id":101, ...       "AllCustomerDetails": ...       { ...          "SomeCustomerDetail1": ...          { ...       ... Read More

How to print document value in MongoDB shell?

Nishtha Thakur

Nishtha Thakur

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

2K+ Views

For this, work with the concept of forEach(). Let us first create a collection with documents −> db.printDocuementValueDemo.insertOne({"InstructorName":"John Smith"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd6804f7924bb85b3f48950") } > db.printDocuementValueDemo.insertOne({"InstructorName":"Sam Williams"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd680577924bb85b3f48951") } > db.printDocuementValueDemo.insertOne({"InstructorName":"David Miller"}); {    "acknowledged" : true, ... Read More

Advertisements