Wednesday, 1 May 2013

Company Employe Include in a list That Have Sialry and name and residanse in c++ and OOP'S


#include<conio.h>
#include<iostream.h>
class college
{
char name[10];
char res[10];
public:
void indata()
{
cout<<"Enter the name";
cin>>name;
cout<<"Enter the residence";
cin>>res;
}
void display()
{
cout<<"The name is"<<name<<endl;
cout<<"The residence is"<<res<<endl;
}
};
class office:public college
{
int age;
int salary;
char des[10];
public:
void indata1()
{
cout<<"Enter the age"<<endl;
cin>>age;
cout<<"Enter salary"<<endl;
cin>>salary;
cout<<"Enter designation"<<endl;
cin>>des;
 }
void display1()
 {
cout<<"The age="<<age<<endl;
cout<<"The salary="<<salary<<endl;
cout<<"The designation is:" <<des<<endl;
}
} ;
class collegues:public office
{
char looks[10];
char comp[10];
public:
void indata2()
{
indata();
indata1();
cout<<"Enter the looks"<<endl;
cin>>looks;
cout<<"Enter the complexion"<<endl;
cin>>comp;
cout<<endl;
}
void display2()
{
display();
display1();
cout<<"Looks:" <<looks<<endl;
cout<<"Complexion:"<<comp<<endl;
}
} ;
void main()
{
clrscr();
collegues c;
c.indata2();
c.display2();
getch();
}

GraphDriver use At C++ OR OOP'S


#include<chandra.h>

// Global Variable Declaration..

int GraphDriver = DETECT; /* Request auto-detection */
int GraphMode;
void func_gen(float ,float ,float ,int, int, int);
void drawAxis();
void graph();
float mod(float );
void yx1(float );
void yx2(float );
float graphFunction(float );

//Main Function

void main()
{
initgraph( &GraphDriver, &GraphMode, "../bgi" );
    char c;
    int zoom_factor=10, xsh=0, ysh=0;
    float precision=0.01, min_range=-30, max_range=30;
    func_gen(precision,min_range,max_range,zoom_factor,xsh,ysh);
  do{
    c=getch();

    if(c=='w'||c=='W')
    {
      precision=precision/10;
      func_gen(precision,min_range,max_range,zoom_factor,xsh,ysh);
    }

    if(c=='q'||c=='Q')
    {
      precision=precision*10;
      func_gen(precision,min_range,max_range,zoom_factor,xsh,ysh);
    }

    if(c=='+')
    {
      zoom_factor +=2;
      func_gen(precision,min_range,max_range,zoom_factor,xsh,ysh);
    }

    if(c=='-')
    {
      zoom_factor -=2;
      func_gen(precision,min_range,max_range,zoom_factor,xsh,ysh);
    }

    if(c=='x' || c=='x')
    {
      ysh += 2;
      func_gen(precision,min_range,max_range,zoom_factor,xsh,ysh);
    }

     if(c=='s' || c=='S')
    {
      xsh += 2;
      func_gen(precision,min_range,max_range,zoom_factor,xsh,ysh);
    }

    if(c=='c' || c=='C')
    {
      ysh -= 2;
      func_gen(precision,min_range,max_range,zoom_factor,xsh,ysh);
    }

     if(c=='A' || c=='a')
    {
      xsh -= 2;
      func_gen(precision,min_range,max_range,zoom_factor,xsh,ysh);
    }

    if(c=='R' || c=='r')
    {
      ysh = 0;
      xsh = 0;
      precision = 0.1;
      zoom_factor=10;
      func_gen(precision,min_range,max_range,zoom_factor,xsh,ysh);
    }

    }
    while(c=='w'||c=='W'||c=='q'||c=='Q'||c=='+'||c=='-'||c=='s'||c=='S'||c=='x'||c=='X'||c=='a'||c=='A'||c=='c'||c=='C'||c=='r'||c=='R');

    closegraph();
}

//Mod Function

float mod(float x)
{
 if(x<0)
 return (-1)*x;

 else
 return x;

}

// COORDINATE AXIS

void yx1(float min_range, float max_range)
{

    float x=min_range;
    while(x<=max_range)
    { float y;

      y = x;


    float xcord=320+10*x;
    float ycord=240-10*y;
    if((xcord<=640 && xcord>=0) && (ycord>=0 && ycord<=480))
putpixel(xcord,ycord,50);
x += 0.1;
     }

}

void yx2(float min_range, float max_range)
{

    float x=min_range;
    while(x<=max_range)
    { float y;

      y = -1*x;


    float xcord=320+10*x;
    float ycord=240-10*y;
    if((xcord<=640 && xcord>=0) && (ycord>=0 && ycord<=480))
putpixel(xcord,ycord,50);
x += 0.1;
     }

}


void drawAxis()
{
      int i=0;
      while(i!=480)
      {   putpixel(320,i,1);
 i++;
      }

      i=0;
      while(i!=640)
      {  putpixel(i,240,1);
i++;
      }

}
/*
void graph()
{
int k=20, i=0;

     while(k<480)
     {
while(i<640)
{
 putpixel(i,k,5);
 i++;
}
i=0;
k += 20;
     }


k=20, i=0;

     while(k<640)
     {
while(i<480)
{
 putpixel(k,i,5);
 i++;
}
i=0;
k += 20;
     }
}
*/
void func_gen(float precision,float min_range, float max_range, int zoom_factor, int xsh, int ysh)
{
 cleardevice();
// graph();
 drawAxis();
 yx1(min_range, max_range);
 yx2(min_range, max_range);

  int color=(34);
  float x=min_range;
    while(x<=max_range)
    { float y;

      y = graphFunction(x);    //define a function
//   outtextxy(0,0,"Func_gen By Sunil Kumar Dheendhwal");

    float xcord=320+zoom_factor*x+xsh;
    float ycord=240-zoom_factor*y+ysh;

    if((xcord<=640 && xcord>=0) && (ycord>=0 && ycord<=480))
putpixel(xcord,ycord,random(color));
x=x+precision;
    }
}


float graphFunction(float x)
{

return x+10;

}

constructer and distructer in C++ and OOP'S


#include<iostream.h>
#include<conio.h>
int count=0;
class alpha
{
public:
alpha()
{
count++;
cout<<"Call of constructer ="<<count<<endl;
}
~alpha()
{
cout<<"Call of distructer="<<count<<endl;
count--;
}
};
void main()
{
clrscr();
{
alpha a1,a2,a3 ;
{
cout<<"Enter into the block";
alpha a4 ;
cout<<"Exit from the block";
}
}
getch();
}

File HAndling In C++ Or OOP'S


#include<fstream.h>
#include<process.h>
int main()
{
char ch;
ofstream of("team.doc");
if(!of)
{
cerr<<"file cannot open correctly";
exit(-1);
}
cin.get(ch);
while(ch!='\n')
{
of.put(ch);
cin.get(ch);
}
return 0;
}