Effective commenting and tabbing will affect your grade. The \"style\" of your p
ID: 3670638 • Letter: E
Question
Effective commenting and tabbing will affect your grade. The "style" of your program should follow the style of the sample programs in the course notes. Your program should have the file name, your name, creation and last modification dates and a brief description of the program in the comments at the top of the program. The declaration of every variable should have a comment. Write a program that prints an hour glass using the character The user will enter the number of !#A s on the top row and then the number of rows from the top to the middle row. For instance, an hour glass with 7 '#'s in the top row and with 3 rows from the top row to the middle row looks like:Explanation / Answer
#include <bits/stdc++.h>
using namespace std;
int main(){
cout << "Enter top row count: ";
int n;
cin >> n;
int cnt = n;
int sub;
for(sub = 0; cnt >= 3; sub++){
for(int i = 0; i < sub; i++)
cout << " ";
for(int i = 0; i < cnt; i++)
cout << "#";
cnt -= 2;
cout << endl;
}
cnt = 5;
sub -= 2;
for(; cnt <= n; sub--){
for(int i = 0; i < sub; i++)
cout << " ";
for(int i = 0; i < cnt; i++)
cout << "#";
cnt += 2;
cout << endl;
}
return 0;
}