2) ( 60p) Write a C program that reads a number n from the user and allows to print a house with a roof using ‘*’ characters. Th
e house should be a n x n square and the roof two diagonal lines of 45 degrees forming a roof (if n is odd the roof closes in the top perfectly).
1 answer:
Answer:
Explanation:
#include <iostream>
using namespace std;
int printroofln(int, int);
int printbodyln(int, int);
int main()
{
int hgt=0,odd=0,rhgt=0;
cout<<"Enter the height:";
cin>>hgt;
if ((hgt%2)==1) rhgt=(hgt/2)+1;
else rhgt=hgt/2;
for (int i=0;i<rhgt;i++)
{
printroofln(i,hgt);
}
for (int j=0;j<hgt;j++)
{
printbodyln(j,hgt);
}
return 0;
}
int printroofln(int rfln, int hgt)
{
int id1,id2,hlf=0;
hlf=hgt/2;
if ((hgt%2)==1)
{
id1=hlf-rfln;
id2=hlf+rfln;
}
else
{
id1=hlf-rfln-1;
id2=hlf+rfln;
}
for (int i=0;i<=hgt;i++)
{
if ((id1==i)||(id2==i))
cout<<"*";
else
cout<<" ";
}
cout<<endl;
return 0;
}
int printbodyln(int bln, int hgt)
{
for (int i=0;i<hgt;i++)
{
if ((bln==0)||(bln==(hgt-1))||(i==0)||(i==(hgt-1)))
{
cout<<"*";
}
else
{
cout<<" ";
}
}
cout<<endl;
return 0;
}
You might be interested in
Try refreshing the page, if not restart your device check your internet etc.
Ethics is the answer I believe
E. Transaction processing system
Explanation:
He will need a transaction processing system to know the amount of logistics available daily and how many to ship and how many to order.
Transaction processing system will make him keep track of what transactions take place during the various days to help him give a good report.
Override only
Reason because the same method speak is in the parent and child class
So this is your answer hope this helps you
C++