Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Task 1 Task 1 is to copy and paste the code below into the project. This code asks the user for a height and then
Task
Task is to copy and paste the code below into the project. This code asks the user for a height and then prints out a sideways pyramid. For example, the goal is to produce this output with a height of although the actual code will be slightly wrongwe'll fix that in Task Copypaste or type your code here
Lab template code, CS
Write and run the tests for the individual problems one at a time.
#include
#include for setw and setfill
using namespace std;
main is where our program begins
int main
Create a height variable and get the input from the user
int height;
cout "Enter the height: ;
cin height;
Use a while loop to count up from to the height
int level ;
while level height
Note that just outputs one backslash: is a special character in C
so we just repeat it to clarify we really mean a backslash
endl starts for "end line" and will output a new line for us
As explained in Task setw specifies how many characters
should be output when we display the backslash
cout setwlevel endl;
Add one to level
level;
Now start at height, and count down to
level height;
while level
cout setwlevel endl;
Subtract one from level
level;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started