Generate Random Numbers in C++

We generate random numbers in C++ because it is used mostly in games and other automatic stuff. To Generate random numbers  we need some ready  made libraries, we use the library...

Generation of Prime Numbers in C++

Implementing the logic of Prime Numbers into our c++ code, we need simple for loops and conditional statements. This is very easy to implement and print Prime Numbers upto 1000. Lets...

Hello World in C++

The Hello world program is a simple computer program that prints (or displays) the string "Hello, world!" or some variant thereof. It is typically one of the simplest programs possible...

Classes with applications in C++

Classes are defined by using the keyword “ class ”  and have a body closed in braces {}  just like structures and ends with a semicolon( ; ). We cannot initialize...

Assignment Operator Overloading in C++

After we do assignment operator overloading, we will then be able to assign two variables of our self-defined datatypes. Lets have a look at the below example: // Operator overloading in C++ //assignment operator overloading #include<iostream> using namespace std;   class Employee { private:     int idNum;     double salary; public:     Employee ( ) {         idNum = 0, salary = 0.0;     }       void setValues (int a, int b);     void operator= (Employee&emp );   };   void Employee::setValues ( int idN , int sal ) {       salary = sal; idNum = idN;   }   void Employee::operator = (Employee&emp)  // Assignment operator function {     salary = emp.salary; }   int main ( ) {       Employee emp1;     emp1.setValues(10,33);     Employee emp2;     emp2 = emp1;        // emp2 is calling object using assignment operator   } Now lets explain this...

Finding Greatest Common Divisor of 2 numbers in C++

As we know that greatest common divisor of 2 numbers is the largest number that divides both those numbers, How we implement this logic in C++, its given in the below...

C++ Program to find largest of 3 numbers

In C++ we can implement a logic to write a program to find largest of 3 numbers. So for finding maximum number from given two, three or more numbers, this is...

Fractional Calculator in C++

We can easily use structures to create a fractional calculator than can solve fractional numbers in C++. It is just an easy approach through structures, we can easily create a simple...

Binomial Coefficients in C++

How we implement a logic to find out the binomial coefficients of an entered number by the user in C++?. Look at the below code: # include <iostream> ...

Control structures in C++

Control structures in C++ also called the decision makers. In C++ We have control structures which are helpful in programs which needs a little bit concept of decision making between different...