Posts

Showing posts from February, 2018

Object Oriented Paradigm

Object Oriented Paradigm Object Oriented Paradigm also called oop is a model for writing computer programs. Features of OOP Abstraction. Encapsulation. Polymorphism. Inheritance. Abstraction Using the essential feature of a programming language  and hiding the complexity is known as abstraction. Encapsulation Wrapping of data members & the member function within the class is known as Encapsulation. It is based on the concept of data hiding & data hiding says that we can't access the private element of class without the help of member function of that class. Polymorphism Ability to assume several forms is known as polymorphism and we can achieve polymorphism in C++ by 3 ways. By function Overloading. Operator Overloading. Virtual Function. Inheritance It is taken from the real world where the parent class is known as base class and the child class is known as derived class. It says that child class can access all property o...

C++ program to print factors of a number using class.

Note: Use new compiler (Code blocks or Dev C++)  to run these C++ programs. Old  Turbo C compiler does not supports some new features of C++. If you want to run these programs on old Turbo C++ compiler use  <iostream.h>  instead of  <iostream>  , do not use (  using namespace std;  ) , use {  getch();  } to hold run-time screen , use  void main()  instead of  int main()  . #include<iostream> using namespace std; class factors {   public:   void display(int u)   {     int num = u;      int i=2,j,fact;            while(num!=0)         {                    if (num%i==0)             {               cout << i;             ...

C++ program to print 0 10 010 1010 pattern using class

Note: Use new compiler (Code blocks or Dev C++)  to run these C++ programs. Old  Turbo C compiler does not supports some new features of C++. If you want to run these programs on old Turbo C++ compiler use <iostream.h> instead of <iostream> , do not use ( using namespace std; ) , use { getch(); } to hold run-time screen , use void main() instead of int main() . 0    1 0       0 1 0          1 0 1 0             0 1 0 1 0 #include<iostream> class pattern {   public:    void display()     {      int i, j, k = 1;            for(i=1; i<=5; i++)       {         for(j=1; j<=i; j++)         {           if( k % 2  == 0 )            cout <...

C++ program to print number pyramid 1 121 12321 1234321 using class.

Note: Use new compiler (Code blocks or Dev C++)  to run these C++ programs. Old  Turbo C compiler does not supports some new features of C++. If you want to run these programs on old Turbo C++ compiler use  <iostream.h>  instead of  <iostream>  , do not use (  using namespace std;  ) , use {  getch();  } to hold run-time screen , use  void main()  instead of  int main()  . 1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1 #include<iostream> using namespace std; class xyz {   public:    void display()     {      int  i, j, k, l, x=3;             for(i=1; i<=4; i++)       {        for(j=0; j<=x; j++)          cout <<" ";                  for(k=1; k<=...

A simple C++ program using class

Note: Use new compiler (Code blocks or Dev C++)  to run these C++ programs. Old  Turbo C compiler does not supports some new features of C++. If you want to run these programs on old Turbo C++ compiler use   <iostream.h>  instead of  <iostream>  , do not use (  using namespace std;  ) , use {  getch();  } to hold run-time screen , use  void main()  instead of  int main()  . C++ program to check a number weather palindrome or not.  #include<iostream> using namespace std; class palindrome {    private:    int num;    public:    void get(int u)    {      num = u;    }        void disp()    {        int temp, rem, rev;       temp = num;             while(n...

A Simple C++ Program

Printing a string using C++ Note: Use new compiler (Code blocks or Dev C++)  to run these C++ programs. Old  Turbo C compiler does not supports some new features of C++. If you want to run these programs on old Turbo C++ compiler use  <iostream.h>  instead of  <iostream>  , do not use (  using namespace std;  ) , use {  getch();  } to hold run-time screen , use  void main()  instead of  int main()  . Simple Program to print a string in C++ #include<iostream>       \\Include Header File using namespace std; int main() {    cout << "Printing a simple String \n";    \\ C++ statement      return 0; } C++ Program to calculate sum of two numbers #include<iostream>      using namespace std; int main() {   int a,b,sum;   cout << "Enter two numbers. \...