Your Ad Here

Sunday, June 1, 2008

Simple C++ program

/* C++ program on Computer Details */

#include< iostream.h>
#include< conio.h>
#define max 80

int y;
int a = 0;
int b = 0;
long c = 0;
int d,m,p;

class computer
{
private:
char s[10],x[10],h[10];

public:
void getdata()
{
cout< < "Enter Computer Type : ";
cin>>h;
cout< < endl;
cout< < "Enter CPU Type : ";
cin>>x;
cout< < endl;
cout< < "Enter The Type Of OS : ";
cin>>s;
cout< < endl;
cout< < "Enter The Memory In MB : ";
cin>>m;
cout< < endl;
cout< < "Enter The Disk Space In GB : ";
cin>>d;
cout< < endl;
cout< < "Enter Yhe Price : ";
cin>>p;
cout< < endl;
}

int compare(int i)
{
if(m>a)
{
a = m;
b = d;
c = p;
y = i;
}
if((m==a)&&(d< b))
{
a = m;
b = d;
c = p;
y = i;
}
if((m==a)&&(d==b)&&(p< c))
{
a = m;
b = d;
c = p;
y = i;
}
return y;
}

void display()
{
cout< < "The Details Of The Best Computer Are : ";
cout< < endl;
cout< < "Disk Space :"< < d;
cout< < endl;
cout< < "Memory Space :"< < m;
cout< < endl;
cout< <"Price: "< < p;
cout< < endl;
cout< < "OS : "< < s;
cout< < endl;
cout< < "CPU : "< < x;
cout< < endl;
cout< < "Computer : "< < h;
cout< < endl;
}

};
void main()
{
clrscr();
computer d[max];
int r;
cout< < "Enter The Range : ";
cin>>r;
cout< < endl;

for(int i=0;i< r;i++)
{
d[i].getdata();
}
for(int j=0;j< r;j++)
{
d[j].compare(j);
}
d[y].display();
getch();
}

No comments:

Your Ad Here