Posted by MindBreaker at 2:25 PM
Read our previous post
Create a
structure called RoomArea that uses two variables of type distance (it is a
structure having two variables
feet and
inches) to model the area of a room. Initialize a variable of RoomArea and
calculate area of a room.
Source code
#include <iostream>
#include <string>
using namespace std;
struct
RoomArea
{
int feet;
float
inches;
};
void
main()
{
RoomArea r1,r2;
RoomArea r3 = {10,5.5};
cout << "Enter
feet" << endl;
cin >> r1.feet;
cout << "Enter
inches" << endl;
cin >> r1.inches;
r3.inches = r1.inches + r2.inches;
r3.feet = 0;
if(r3.inches
>= 12.0)
{
r3.inches= 12.0;
r3.feet--;
}
r3.feet = r3.feet + r1.feet + r2.feet;
cout << r1.feet << " " << r1.inches << endl;
cout << r2.feet << " " << r2.inches << endl;
cout << r3.feet << " " << r3.inches << endl;
}
Output
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.