
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 33676 Articles for Programming

203 Views
In this section we will see what is the conversion constructor or converting constructor in C++ class. A constructor is a special type of function of class. It has some unique property like, its name will be same as class name, it will not return any value etc. The constructors are used to construct objects of a class. Sometimes constructors may take some arguments, or sometimes it does not take arguments.When a constructor takes only one argument then this type of constructors becomes conversion constructor. This type of constructor allows automatic conversion to the class being constructed.Example#include using namespace std; ... Read More

6K+ Views
In C++ we have seen there is character type data called char. Sometimes we have seen unsigned char also. So here we will see what is basically the unsigned char means. What are the basic differences between signed char and unsigned char?Signed char and unsigned char both are used to store single character. The variable stores the ASCII value of the characters. For an example if ‘A’ is stored, actually it will hold 65. For signed char we need not to write the signed keyword. But for unsigned, we have to mention the keyword. The syntax is like below.unsigned char ... Read More

817 Views
Sometimes we can find the keyword ‘const’ present at the last of function declaration. So what does it mean?Using this one function can be made as constant. The idea of constant function is that, the function cannot be modified from the objects, where they are called. It is recommended to use the constant functions in our program.Let us see one example of constant function.Example#include using namespace std; class MyClass { int value; public: MyClass(int val = 0) { value = val; } int getVal() const ... Read More

24K+ Views
Here we will see how to initialize the private static member variables initialization in C++. We can put static members (Functions or Variables) in C++ classes. For the static variables, we have to initialize them after defining the class.To initialize we have to use the class name then scope resolution operator (::), then the variable name. Now we can assign some value.The following code will illustrate the of static member initializing technique.Example#include using namespace std; class MyClass{ private: static int st_var; public: MyClass(){ st_var++; //increase the value ... Read More

593 Views
The Baillie-PSW Primality Test, this test named after Robert Baillie, Carl Pomerance, John Selfridge, and Samuel Wagstaff. It is a test which tests whether a number is a composite number or possibly prime.AlgorithmMillerTest()Begin Declare a function MillerTest of Boolean type. Declare MT_dt and MT_num of integer datatype and pass as the parameter. Declare MT_a and MT_x of integer datatype. Initialize MT_a = 2 + rand( ) % (MT_num - 4). Initialize MT_x = pow(MT_a, MT_dt, MT_num). if (MT_x == 1 || MT_x == MT_num - 1) then ... Read More

328 Views
Solovay-Strassen Primality Test is used to test a number whether it is a composite or possibly prime number.AlgorithmsBegin Declare a function modulo to the long datatype to perform binary calculation. Declare m_base, m_exp, m_mod of long datatype and pass them as a parameter. Declare two variables a, b of long datatype. Initialize a = 1, b = m_base. while (m_exp > 0) do if (m_exp % 2 == 1) then a = (a * b) % ... Read More

727 Views
To find the Vertex Connectivity of a graph we need to find out Articulation Points of that graph. Articulation Points (or Cut Vertices) in a Graph is a point iff removing it (and edges through it) disconnects the graph. An articulation point for a disconnected undirected graph, is a vertex removing which increases number of connected components.AlgorithmBegin We use dfs here to find articulation point: In DFS, a vertex w is articulation point if one of the following two conditions is satisfied. 1) w is root of DFS tree and it has at least two children. ... Read More

600 Views
In this program to find the maximum Cut in a graph, we need to find the Edge Connectivity of a Graph. An Edge Connectivity of a Graph of a graph means it is a bridge, removing it graph will be disconnected. Number of connected components increases with the removing of bridge in a disconnected undirected graph.Functions and pseudocodeBegin Function connections() is a recursive function to find out the connections: A) Mark the current node un visited. B) Initialize time and low value C) Go through all vertices adjacent to this D) Check if the subtree ... Read More

890 Views
Weakly or Strongly Connected for a given a undirected graph can be found out using DFS. This is a C++ program of this problem.Functions usedBegin Function fillorder() = fill stack with all the vertices. a) Mark the current node as visited and print it b) Recur for all the vertices adjacent to this vertex c) All vertices reachable from v are processed by now, push v to Stack End Begin Function DFS() : a) Mark the current node as visited and print it b) Recur for all the vertices adjacent to this vertex EndExample#include ... Read More

688 Views
Weakly or Strongly Connected for a given a directed graph can be found out using DFS. This is a C++ program of this problem.Functions usedBegin Function fillorder() = fill stack with all the vertices. a) Mark the current node as visited and print it b) Recur for all the vertices adjacent to this vertex c) All vertices reachable from v are processed by now, push v to Stack End Begin Function DFS() : a) Mark the current node as visited and print it b) Recur for all the vertices adjacent to this vertex EndExample#include ... Read More