upsidedown

oops exp4 abc-rp

Feb 24th, 2012
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.31 KB | None | 0 0
  1. #include<iostream.h>
  2. class ABC;
  3. class XYZ
  4. {
  5.     int a;
  6. public :
  7.     friend void max(XYZ,ABC);
  8. };
  9.  
  10. class ABC
  11. {
  12.     int b;
  13. public:
  14.     friend void max(XYZ,ABC);
  15. };
  16.  
  17. void max(XYZ p,ABC q)
  18. {
  19.     cout<<"enter two values to find the max:\n";
  20.     cin>>p.a>>q.b;
  21.     if(p.a>=q.b)
  22.         cout<<"the greatest is "<<p.a<<endl;
  23.     else
  24.         cout<<"the greatest is "<<q.b<<endl;
  25. }
  26.  
  27. int main()
  28. {
  29.     XYZ q;
  30.     ABC w;
  31.     max(q,w);
  32.     return 0;
  33. }
  34.  
  35. #include<iostream.h>
  36. class ABC;
  37. class XYZ
  38. {
  39.     int a;
  40. public :
  41.     friend void max(XYZ,ABC);
  42. };
  43.  
  44. class ABC
  45. {
  46.     int b;
  47. public:
  48.     friend void max(XYZ,ABC);
  49. };
  50.  
  51. void max(XYZ p,ABC q)
  52. {
  53.     int avg;
  54.     cout<<"enter two values to find the average:\n";
  55.     cin>>p.a>>q.b;
  56.     avg=(p.a+q.b)/2;
  57.     cout<<"the average of "<<p.a<<" and "<<q.b<<" is "<<avg<<endl;
  58. }
  59.  
  60. int main()
  61. {
  62.     XYZ q;
  63.     ABC w;
  64.     max(q,w);
  65.     return 0;
  66. }
  67.  
  68. #include<iostream.h>
  69. class ABC;
  70. class XYZ
  71. {
  72.     int a;
  73. public :
  74.     friend void max(XYZ,ABC);
  75. };
  76.  
  77. class ABC
  78. {
  79.     int b;
  80. public:
  81.     friend void max(XYZ,ABC);
  82. };
  83.  
  84. void max(XYZ p,ABC q)
  85. {
  86.     int t=0;
  87.     cout<<"enter two values to swap:\n";
  88.     cin>>p.a>>q.b;      
  89.     cout<<"values before swapping are a= "<<p.a<<" b= "<<q.b<<endl;
  90.     t=p.a;
  91.     p.a=q.b;
  92.     q.b=t;
  93.     cout<<"values after swapping are a= "<<p.a<<" b= "<<q.b<<endl;
  94. }
  95.  
  96. int main()
  97. {
  98.     XYZ q;
  99.     ABC w;
  100.     max(q,w);
  101.     return 0;
  102. }
Advertisement
Add Comment
Please, Sign In to add comment