Category: CPP


In this post,  bubble sort is written in C++ using class. #include<iostream> using namespace std; class BubbleSort { int a[20]; public: int *bubblesort(int *, int); }; int* BubbleSort :: bubblesort( int a[], int n) { int i, j, t; for( Read more…


Templates are used to support generic programming  in C++, what happens when you need a function of a class that takes its argument  as float as well as integer. You have to declare and define two functions, the first one  Read more…


Polymorphism Feature in C++ Polymorphism means single name but multiple formats and this is one of the crucial features of C++. Furthermore, when there are multiple formats of a single function then choosing an appropriate version of the function is Read more…


Inheritance in C++Inheritance is a very important feature of object-oriented programming approach. Further, which provides the mechanism of reusability of classes. Moreover, it is very important to reuse classes which are tested. And this idea also saves resources and increases Read more…


Sum of Natural Numbers in C++ Program Description- In this program, a class Sum is declared. Which has two public variables n and i and a public function sum_of_n() which takes an integer argument( user should provide a natural number) Read more…


Factorial in CPP Using Class Program Description- Program that calculates factorial in cpp of a natural number. Further, a class Fact is declared in which there are two public integer  variables  which are n and i and a public function Read more…


Add Two Numbers in CPP #include<iostream> using namespace std; int main() { int x, y, sum; cout<<” Enter Two Numbers for Addition”<<endl; cin>>x>>y; sum = x + y; cout<< “Sum of Two Numbers is”<<“n”<<sum; return 0; } ___________________________ For output Read more…