Tuesday, July 24, 2012

program to Remove duplicate character from a string


//this program uses the function of string library

#include <iostream>
#include <string>
using namespace std;

int main()
{
    string str1 = "silicon ABC ADC BCA";
    string str2;
    int pos;


    for(int i = 0; i < str1.length(); i++)
    {
        if( (pos = str2.find(str1[i])) < 0)
            str2 += str1[i];
    }


    cout << str2 << endl;
    return 0;
}


OUPUT:

Online software training website

  1. lynda.com
  2. wibit.net
  3. pluralsight
  4. vtc
  5. tutsplus
  6. video to brain
  7. infinity skills
  8. udemy
  9. informIT

Tuesday, July 17, 2012

List of IDE/Compilers for c++ environment in linux or windows

Linux:
  1. GCC
  2. Code::Block IDE (using GCC for compilation)
  3. EclipseIDE
  4. Net beans IDE
  5. QT framework

Windows: 
  1. Visual c++
  2. Dev c++
  3. Code::block IDE (using GCC for compilation)
  4. MinGW (GCC version for windows)  
  5. Eclipse IDE
  6. Net beans IDE
  7. MinGW64
  8. Visual studio .net framework
  9. QT framework

Cross Platforms:
  1. Eclipse IDE (linux, windows, mac)
  2. Net beans IDE (linux, windows)
  3. Code::block IDE (linux, windows)
  4. QT framework

code to understand Pure Virtual Function

#include <iostream>
using namespace std;

class Cat{
    public:
        int mAge;
        int mWeight;
       
        virtual void innoculate()=0;
};

class Persian: public Cat
{
    public:
        virtual void innoculate()

        {
            cout << "successful innoculated" << endl;
        }
};

int main()
{
        //Cat c2; gives error: because Cat is a abstract class
    Persian c1;
    c1.innoculate();
    return 0;
}


OUTPUT:

Wednesday, July 11, 2012

A program to print febonacci series upto first 20 trems

#include <stdio.h>
#include <conio.h>

int main()
{
    int a = 0;
    int b = 1;
    int i,sum;
    
    for(i = 0;i<20;i++)
    {
        sum = a+b;
        printf("%d\n",sum);
         
        a = b;
        b = sum;
    }
}

A program to print the FIBONACCI series


#include<iostream>
using namespace std;

main()
{
   int n, c, first = 0, second = 1, next;

   cout << "Enter the number of terms of Fibonacci series you want" << endl;
   cin >> n;

   cout << "First " << n << " terms of Fibonacci series are :- " << endl;

   for ( c = 0 ; c < n ; c++ )
   {
      if ( c <= 1 )
         next = c;


      else
      {
         next = first + second;
         first = second;
         second = next;
      }
      cout << next << endl;
   }
}

Monday, July 2, 2012

Relation between class_Size and inheritance

#include <iostream>
using namespace std;

class Base
{
    int first_int;           //size of int is 4 byte
    int second_int;       //so size of Base class is 8 byte
};

class derived:public Base
{
    int derived_member;
    int another_derived_member;
    int new_member;
};

class home
{
    Base base_1;
    Base base_2;
};

int main()
{
    cout << sizeof(derived) << endl;     //the size of derived class is (8+12=20) byte
    cout << sizeof(Base)    << endl;
    cout << sizeof(home)   << endl;      //the size of home class is (8+8)=16 byte
}


OUTPUT:
20
8
16