Showing posts with label classes. Show all posts
Showing posts with label classes. Show all posts

Wednesday, 2 May 2012

Program Of IF Statement With Class In C++

#include<iostream.h>
#include<conio.h>
class test
{
private:
int a;
public:
{
cout<<"Enter Marks=";
cin>>a;
}
void show()
{
if(a>=40)
{
cout<<"\n Pass";
}
else
{
cout<<"\n Fail";
}

}


};
main()
{
clrscr();
t1.getdata();
t1.show();
getch();
}

Friday, 27 April 2012

Program Of Type Conversion Between Derive to Base Class

#include <iostream.h>
#include<conio.h>
class Base
{
private:
    double b;
public:
    {
     b=x;
    }
    void display()
    {
cout<<"\n Base Class Value Is"<<b;
    }
    double getValue()
    {
return b;
    }
};
class derive
{
private:
    int d;
public:
    derive(int y)
    {
     d=y;
    }
    void display()
    {
      cout << "\n derive Value Is"<<d;
    }
    {
return Base(d*1.609344);
    }
};
main()
{
clrscr();
    derive m1 = 100;        // Source Class
    Base k1 = m1;         // Destination Class
    m1.display();
    k1.display();
    cout << endl;
   getch();
}

Sunday, 15 January 2012

Program To Find Simple Interest Using Class In C++


  #include<iostream.h>
    #include<conio.h>
    #include<math.h>
    class pawan
      {
private:
float x,y,z;
public:
{
x=p;
y=q;
z=r;
}
void display()
 {
float m,l,j,k;
m=(l*j*k/100);
cout<<m;
   }
     };
    main()
{
pawan a1;
clrscr();
float a,b,c;
cout<<"entaer numbers x,y,z=";
cin>>a>>b>>c;
a1. getdata(a,b,c);
a1.display();
getch();
}