BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan

BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan (http://bzupages.com/)
-   Object Oriented Programming (http://bzupages.com/35-object-oriented-programming/)
-   -   Find the AREA of a Home By using Nested Struct C++ (http://bzupages.com/f35/find-area-home-using-nested-struct-c-678/)

shmsa 02-09-2008 03:25 PM

Find the AREA of a Home By using Nested Struct C++
 
THE AREA is in ASSignment


Code:

#include
using namespace std;
struct dist
{
int feet;
int inches;
};
struct room
{
dist length;
dist width;
}r1,r2,r3,tot,totareaf,totareai;
int main()
{

r1.length.feet=5;
r1.length.inches=3;
r1.width.feet=5;
r1.width.inches=3;

r2.length.feet=5;
r2.length.inches=3;
r2.width.feet=5;
r2.width.inches=3;

r3.length.feet=5;
r3.length.inches=3;
r3.width.feet=5;
r3.width.inches=3;


tot.length.feet=r1.length.feet+r2.length.feet+r3.length.feet;
tot.length.inches=r1.length.inches+r2.length.inches+r3.length.inches;

tot.width.feet=r1.width.feet+r2.width.feet+r3.width.feet;
tot.width.inches=r1.width.inches+r2.width.inches+r3.width.inches;




if(tot.length.inches>=12)
{
tot.length.feet+=tot.length.inches/12;
tot.length.inches=tot.length.inches % 12;
}

if(tot.width.inches>=12)
{
tot.width.feet+=tot.width.inches/12;
tot.width.inches=tot.width.inches % 12;
}



cout<<"total length "< cout<<"total width "<
totareaf.length.feet=tot.length.feet*tot.width.feet;
totareai.length.inches=tot.length.inches*tot.width.inches;

if(totareai.length.inches>=12)
{
totareaf.length.feet+=totareai.length.inches/12;
totareai.length.inches=totareai.length.inches% 12;
}



cout<<"The Total Area of the house is "<


return 0;
}


BSIT07-01 03-09-2008 01:34 AM

Re: Find the AREA of a Home By using Nested Struct C++
 
Yeh bhi Hay...
Check it.

Code:

#include
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 = "<     cout<<"Total Width = "<
    areafeet=rsum.length.feet*rsum.width.feet;
    areainches=rsum.length.inches*rsum.width.inches;

    if(areainches>=12)

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

    }

    cout<
return 0;

}


.BZU. 03-09-2008 01:39 AM

Re: Find the AREA of a Home By using Nested Struct C++
 
1 Attachment(s)
Here is the Result...,
Attachment 1344

.BZU. 06-09-2008 12:15 AM

Re: Find the AREA of a Home By using Nested Struct C++
 
Madam nay dono ka wrong kar diya hay... :whip:
hahahha..... Actualy area yeh nahi aa ay ga jo kay hum nay likha hay...:book1:

BSIT07-01 06-09-2008 04:41 AM

Re: Find the AREA of a Home By using Nested Struct C++
 
hmmm; Koi baat nahi...
Ghalat ho gaya hay tu hi sahi hoga na ! Aise thori sahi ho jaye ga..
BTW I've tried to correct it, lakin nahi hua mere se tu..


All times are GMT +5. The time now is 05:13 AM.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.