Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here are the steps that can help you with this C++ problem: And here is the codes so far that I have (I am stuck

image text in transcribed

Here are the steps that can help you with this C++ problem:

image text in transcribed

And here is the codes so far that I have (I am stuck on the BOLDENED steps that create that pyramid shape, so basically I have no clue how to set up the loops)

#include using namespace std;

int main() { // Variable declaration int n; // This variable read in by user // Prompt users for correct n value cout > n; while (n > n; } while (n % 2 == 0) { cout > n; }

// Set up for loops to establish pyramid shape // End program return 0; }

Here are the things you should remember for this problem:

1. This is C++, so please use C++ programming knowledge.

2. Please do not use complicated C++ knowledge, such as array, class, vector, function, string, etc to code this program. I was told that this problem can be coded using only basic for loops and some other understanding of how loops work. I have only covered loops so far, not the aforementioned knowledge.

3. The sample output for the problem is already given above for you to test your code on. So please test your codes to make sure your codes are correct before you post your answer.

4. You should use my work so far to begin with just the loop setup step to save you more time. (Of course, feel free to correct my codes if you see something incorrect).

5. Feel free to add comments to important steps of the loops (e.g explanation of how you set up the loop conditions, as well as your thought process, etc) because I really need to thoroughly understand this problem.

I will give you feedbacks whether your codes are clear and easy to understand. Thanks for the long read!

Write a program pyramid.cpp that reads a positive odd whole number n and prints a pyramid where the last row contains all numbers from n down to 1 (i.e., descending order), the second to last row displays all numbers from n - 1 down to 2, the third to last row displays all numbers from n 2 down to 3, etc. The first row will contain only a single value, i.e. the middle value in the range, i.e. n down to 1. Each successive row contains two more values than the previous row For example, if n is 9, then the program will output 654 76543 8765432 987654321 If n is 13, then the program will output 876 98765 0987654 109876543 21098765432 3210987654321 The i'th row contains 2i 1 values. Each column displays the same number. If a row has more than 10 digits, the digit after 0 should start again from 9

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

More Books

Students also viewed these Databases questions

Question

Use the figure to graph each of the following: v + w V u W

Answered: 1 week ago