CPP program to print factorial of a number

The below program prints factorial of a number using a loop and using recursion. The CPP cout object is used to output the result on the screen. The factorial of a number can be calculated for positive integers only and is represented by n!. n! = n*(n-1)*(n-2)*……*1 0! = 1 Code: Using Loop #include <iostream.h> … Read more

Categories CPP

CPP program to check for a Palindrome number

The below program checks for a Palindrome number using a loop. The CPP cout object is used to output the result on the screen. A number is called as a Palindrome number if the number remains same even when its digits are reversed. Palindrome Number: abcde = edcba Example: 24142, 1234321, etc. Code: #include <iostream.h> … Read more

Categories CPP

CPP program to check prime number

The below program checks if a number is a prime or a composite number. The CPP cout object is used to output the result on the screen. Code: #include <iostream.h> using namespace std;   int main() { int x,i; int count = 0;   cout << "Enter a number:"; cin >> x;   for (i=1; … Read more

Categories CPP

CPP program to print fibonacci series

The below program prints a Fibonacci Series without recursion. The CPP cout object is used to output the result on the screen. A series is called as a Fibonacci series if the each next term of the series is a sum of previous two numbers. Fibonacci Series: a, b, c, d, e   c = … Read more

Categories CPP

CPP Destructor

Unlike CPP Constructors, a CPP destructor is defined only once in a class in order to destroy the objects of that class. It has the same name as the name of the class, prefixed with a tilde sign (~). Example: #include <iostream.h> using namespace std;   class Employees { public: string Name; float Salary; Employees() … Read more

Categories CPP

CPP Constructors

CPP facilitates a special type of method, also called as CPP Constructors, to initialize the instance members of the class and to verify enough object resources for executing any startup task. It has the same name as the name of the class.   Types of Constructors:  Default Constructor: A Default Constructor is automatically created at … Read more

Categories CPP

CPP Object Class

CPP introduced the features of OOPs Concept, i.e, CPP is an object-oriented programming language which uses classes and objects for computations. CPP Class: A collection of Objects is termed as Class in OOPs concept. Every class has its own unique and distinguishable attributes and methods. Syntax: class ClassName: <statement-1>      .      .      .  … Read more

Categories CPP

CPP OOPs Concepts

CPP introduced the features of OOPs Concept, i.e, CPP is an object-oriented programming language which uses classes and objects for computations. However, it is not considered to be truly object-oriented programming language. Advantages of Object Oriented Programming Language: Development and maintenance of is easier than the procedural programming. Easy to solve the real world problems … Read more

Categories CPP

CPP Pointers

CPP pointers can be defined as a variable, pointing towards the address of a value. Syntax: Data_type *variable_Name; CPP Pointer to Pointer: When a pointer refers to the address of another pointer, it is called as Pointer to Pointer in CPP. Syntax: Data_type **variable_Name; Pointer Arithmetic in C: CPP also facilitates Arithmetic operations with Pointers. … Read more

Categories CPP

CPP Multidimensional Arrays

A multidimensional array is an array containing two, three, four, five, or more arrays. The increasing number of dimensions, increases the code complexity for the developers. The most popular arrays are single, two and three dimensional arrays. Two dimensional Arrays: A two-dimensional array can be defined as an array of arrays that needs two indices … Read more

Categories CPP