Friday, 22 June 2012

write a c program using data member's int feet,float inches to represent distance and define function that takes two distance value as argument and return the larger one. include a main program that accept two distance figure from the user compare them and display the larger using inline


/*write a c program using data member's int feet,float inches to represent
distance and define function that takes two distance value as argument
and return the larger one. include a main program that accept two distance
figure from the user  compare them and display the larger using inline
function. */
#include<iostream.h>
#include<conio.h>
class large
{
public:int feet;
       float inches;
public:inline void comp(int f,float inch)
{
f=feet;
inch=inches;
if(f>inch)
cout<<"feet="<<f<<" is greater";
else
cout<<"inches="<<inch<<" is greater";
}
};
int main()
{
large l;
clrscr();
cout<<"enter the feet";
cin>>l.feet;
cout<<"\nenter the inches";
cin>>l.inches;
l.comp(l.feet,l.inches);
getch();
return 0;
}
/****************OUTPUT************************
enter the feet5

enter the inches1.5
feet=5 is greater


enter the feet12

enter the inches12.5
inches=12.5 is greater
******************************************* */

No comments: