Found 33676 Articles for Programming

LocalTime plusNanos() method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

108 Views

An immutable copy of a LocalTime object where some nanoseconds are added to it can be obtained using the plusNanos() method in the LocalTime class in Java. This method requires a single parameter i.e. the number of nanoseconds to be added and it returns the LocalTime object with the added nanoseconds.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo {    public static void main(String[] args) {       LocalTime lt = LocalTime.now();       System.out.println("The current LocalTime is: " + lt);       System.out.println("The LocalTime with 1000 nanoseconds added is: ... Read More

C++ Program to Perform Edge Coloring to the Line Graph of an Input Graph

Farhan Muhamed
Updated on 02-May-2025 18:28:05

385 Views

Edge coloring is a method of coloring the edges of a graph, such that no two edges having a common vertex is colored with same color. A line Graph is a special type of graph which help us to assume an edge-coloring problem into a vertex-coloring problem. In other words, using a line graph makes edge coloring easier. In this article, we will discuss how to perform edge coloring of a graph using line graph and greedy coloring approach. What is Line Graph? Line graph is a special graph that is created from another graph. In the line ... Read More

C++ Program to Perform Graph Coloring on Bipartite Graphs

Farhan Muhamed
Updated on 02-May-2025 18:27:53

546 Views

Graph coloring is a technique in which, we assign colors to the vertices of a graph such that no two adjacent vertices have same color. Bipartite graph a special kind of graph which is possible to color by just two colors. In this article, we will discuss how to perform graph coloring on a bipartite graph using BFS algorithm. What is Bipartite Graph? Bipartite graph is special graph where you can divide the vertices into two sets, such that no two vertices of the same set are connected. This is why, it's possible to color a bipartite graph by ... Read More

Is there a performance difference between i++ and ++i in C++?

Nitya Raut
Updated on 30-Jul-2019 22:30:25

909 Views

There is a big distinction between the suffix and prefix versions of ++.In the prefix version (i.e., ++i), the value of i is incremented, and the value of the expression is the new value of i. So basically it first increments then assigns a value to the expression.In the postfix version (i.e., i++), the value of i is incremented, but the value of the expression is the original value of i. So basically it first assigns a value to expression and then increments the variable.Let's look at some code to get a better understanding.Example Code#include using namespace std; int main() ... Read More

Difference between private, public, and protected inheritance in C++

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

3K+ Views

Data hiding is one of the important features of Object Oriented Programming which allows preventing the functions of a program to access directly the internal representation of a class type. The access restriction to the class members is specified by the labeled access modifiers: public, private, and protected sections within the class body.The default access for members and classes is private.Example Codeclass Base { public:     // public members go here protected: // protected members go here private:     ... Read More

Difference between \'struct\' and \'typedef struct\' in C++ program?

Farhan Muhamed
Updated on 26-May-2025 18:20:27

5K+ Views

In C++ program, struct is a keyword used to define a structure, while typedef is a keyword that is used to create an alias for a data type. In this article, we will discuss the difference between struct and typedef struct in C++. Struct in C++ Struct is a keyword used to define a structure in C++. A structure is a user-defined data type that groups related variables of different data types into a single unit. Struct is same as a class, but the members of a struct are public by default. The syntax for defining a struct is ... Read More

Regular cast vs. static_cast vs. dynamic_cast in C++ program

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

683 Views

static_cast − This is used for the normal/ordinary type conversion. This is also the cast responsible for implicit type coersion and can also be called explicitly. You should use it in cases like converting float to int, char to int, etc.dynamic_cast − This cast is used for handling polymorphism. You only need to use it when you're casting to a derived class. This is exclusively to be used in inheritance when you cast from base class to derived class.Regular Cast − This is the most powerful cast available in C++ as it combines const_cast, static_cast and reinterpret_cast. but it's also ... Read More

What does int argc, char *argv[] mean in C++?

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

1K+ Views

The argc stands for argument count and argv stands for argument values. These are variables passed to main function when it starts executing. When we run a program we can give arguments to that program like:$ ./a.out helloHere hello is an argument to the executable. This can be accessed in your program.Example Code#include using namespace std; int main(int argc, char** argv) {    cout

What is a segmentation fault in C/C++ program?

Farhan Muhamed
Updated on 02-May-2025 18:27:39

1K+ Views

In C++, segmentation fault is a runtime error that occur when your program attempts to access an area of memory that it is not allowed to access. In other words, segmentation fault occur when your program tries to access memory that is beyond the limits that the operating system allocated for your program. These errors are type of access violation that can lead to crashing of program. Segmentation fault occur often with beginner programmers due to the lack of understanding of system level concepts like pointer. In this article, we will explain all the concepts related to segmentation fault, including ... Read More

How to pass objects to functions in C++ Program?

Farhan Muhamed
Updated on 02-May-2025 18:26:45

9K+ Views

The C++ functions can receive objects in multiple ways, depending upon how you want the function to interact with the object. You can either define functions that can modify the original objects or define functions that will make a copy of original object and modify the copy without affecting the original object. In this article, we will explain all the ways to pass an object a C++ function. Pass Objects to Function in C++ Here is the list of all the ways to pass an object to a function in c++ program, which we will be discussing ... Read More

Advertisements