View Single Post
  #2  
Old 03-09-2008, 01:34 AM
BSIT07-01's Avatar
BSIT07-01 BSIT07-01 is offline
Addicted to Computer


 
Join Date: Sep 2007
Location: ------------
Age: 36
Posts: 1,309
Contact Number: ---------------
Program / Discipline: BSIT
Class Roll Number: 07-01
BSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant future
Default Re: Find the AREA of a Home By using Nested Struct C++

Yeh bhi Hay...
Check it.

Code:
#include <iostream>
using namespace std;

struct dist
    {
    int feet;
    int inches;
    };

struct room
    {
    dist width;
    dist length;
    };

room r1,r2,r3,rsum;
int areafeet;
int areainches;

int main()


{
    
    
    r1.width.feet=5;
    r1.width.inches=25;
    r1.length.feet=5;
    r1.length.inches=45;


    r2.width.feet=5;
    r2.width.inches=65;
    r2.length.feet=5;
    r2.length.inches=75;


    r3.width.feet=5;
    r3.width.inches=65;
    r3.length.feet=5;
    r3.length.inches=75;

    rsum.width.feet=r1.width.feet+r2.width.feet+r3.width.feet;

    rsum.width.inches=r1.width.inches+r2.width.inches+r3.width.inches;

    rsum.length.feet=r1.length.feet+r2.length.feet+r3.length.feet;

    rsum.length.inches=r1.length.inches+r2.length.inches+r3.length.inches;


    if(rsum.length.inches>=12)
    {
        rsum.length.feet+=rsum.length.inches/12;

        rsum.length.inches=rsum.length.inches%12;
    }

    if(rsum.width.inches>=12)
    {
        rsum.width.feet+=rsum.length.inches/12;

        rsum.width.inches=rsum.length.inches%12;
    }



    cout<<"Total Length = "<<rsum.length.feet<<"'"<<rsum.length.inches<<"\""<<endl;
    cout<<"Total Width = "<<rsum.width.feet<<"'"<<rsum.width.inches<<"\""<<endl;

    areafeet=rsum.length.feet*rsum.width.feet;
    areainches=rsum.length.inches*rsum.width.inches;

    if(areainches>=12)

    {
        areainches=areainches%12;
        areafeet+=areafeet/12;

    }

    cout<<endl<<"Total area = "<<areafeet<<"'"<<areainches<<"\""<<endl;

return 0;

}

Reply With Quote