upsidedown

oops3_c

Feb 10th, 2012
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include<iostream.h>
  2.  
  3. class area
  4. {
  5. public:
  6.     double r,ht,l,b,a,ba;
  7.  
  8.     double circle()
  9.     {
  10.         return (3.14*r*r);
  11.     }
  12.  
  13.     double triangle()
  14.     {
  15.         return ((ba*ht)/2);
  16.     }
  17.  
  18.     double cube()
  19.     {
  20.         return (a*a*a);
  21.     }
  22.  
  23.     double rect()
  24.     {
  25.         return (l*b);
  26.     }
  27. };
  28.  
  29. int main()
  30. {
  31.     area x;
  32.     cout<<"enter the following data:\n";
  33.     cout<<"radius:\n";
  34.     cin>>x.r;
  35.     cout<<"height and base value of triangle:\n";
  36.     cin>>x.ht>>x.ba;
  37.     cout<<"side if a cube\n";
  38.     cin>>x.a;
  39.     cout<<"lenght and breadth of a rectangle':\n";
  40.     cin>>x.l>>x.b;
  41.     cout<<"the are of the geometrical figures are:\n";
  42.     cout<<"area of circle: "<<x.circle()<<endl;
  43.     cout<<"area of triangle: "<<x.triangle()<<endl;
  44.     cout<<"area of cube: "<<x.cube()<<endl;
  45.     cout<<"area of rectangle: "<<x.rect()<<endl;
  46.     return 0;
  47. }
  48.  
  49. OUTPUT:
  50. enter the following data:
  51. radius:
  52. 5
  53. height and base value of triangle:
  54. 4
  55. 12
  56. side if a cube
  57. 2
  58. lenght and breadth of a rectangle':
  59. 10
  60. 5
  61. the are of the geometrical figures are:
  62. area of circle: 78.5
  63. area of triangle: 24
  64. area of cube: 8
  65. area of rectangle: 50
  66. Press any key to continue
Advertisement
Add Comment
Please, Sign In to add comment