View Single Post
  #1  
Old 02-09-2008, 03:25 PM
shmsa's Avatar
shmsa shmsa is offline
Grown up punk

 
Join Date: Oct 2007
Location: Muslim Town Multan
Posts: 195
Contact Number: 0322-6196713
Program / Discipline: BSIT
Class Roll Number: 07-22
shmsa is a jewel in the roughshmsa is a jewel in the roughshmsa is a jewel in the roughshmsa is a jewel in the rough
lectures Find the AREA of a Home By using Nested Struct C++

THE AREA is in ASSignment


Code:
#include <iostream>
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 "<<tot.length.feet<<"'"<<tot.length.inches<<"\""<<endl;
cout<<"total width "<<tot.width.feet<<"'"<<tot.width.inches<<"\""<<endl;

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 "<<totareaf.length.feet<<"'"<<totareai.length.inches<<"\""<<endl;



return 0;
}


Last edited by BSIT07-01; 03-09-2008 at 01:47 AM. Reason: quoted in CODE
Reply With Quote