Wednesday, May 19, 2010

Addition of two distances using friend function

Share Orkut
15. Create two classes MC and FI which stores values of distances. MC stores distance in meter and cm and FI stores in feet and inches. Write a program that reads and output the values of object of each class and use a friend function to carry out the addition of two distances and produce the result in FI type.

9 comments:

  1. Lavde kya chutiya website banai hai, kitna chota dikh Raha hai ye program.

    ReplyDelete
    Replies
    1. Tere baap ne itna chota hai kya?

      Delete
  2. Nahi Dena hai program thik se toh thik hai na bhai par ye kya bakchodi hai?

    ReplyDelete
  3. Bc lavda mc Kya ha ye

    ReplyDelete
  4. 8 saal ho gayay is chutiya bakchodi ko


    ReplyDelete
  5. #include
    #include
    class fi;
    class mc
    {
       int m,cm;
       public:
       mc()
       {
        m=0;
        cm=0;
       }
       void getdata()
       {
        cout<<"\nEnter the length in meter and centimeter ";
        cin>>m>>cm;
       }
       friend fi add(fi,mc);
    };
    class fi
    {
       int f,i;
       public:
       void getdata()
       {
        cout<<"\nEnter the length in feet and inch ";
        cin>>f>>i;
       }
       void putdata()
       {
        cout<<f<<" feet"<<i<<" inch";
       }
       friend fi add(fi,mc);
    };
    fi add(fi f1,mc m1)
    {
       fi t;
       float j;
       j=m1.m*100+m1.cm;
       j=j*0.393700787;
       t.f=j/12;
       int k=int(j);
       t.i=k%12;
       t.i=t.i+f1.i;
       t.f=(t.i/12)+t.f+f1.f;
       t.i=t.i%12;
       return(t);
    }
    void main()
    {
       clrscr();
       mc m1;
       fi f1,f2;
       m1.getdata();
       f1.getdata();
       f2=add(f1,m1);
       cout<<"\n Sum length ";
       f2.putdata();
       getch();
    }

    ReplyDelete