Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

Question
100%

I have to write an algorithm for the code I made, so please help me.

 

#ifdef _WIN32
#include <Windows.h>
#else
#include <unistd.h>
#endif
#include <iostream>
#include <cstdlib>

using namespace std;

class GenrateShape {        
  public:              
    void SqaureShape(int length) {  
      for (int row = 1; row <= length; row++)
        {
            sleep (1);
            for (int col = 1; col <= length; col++)
            {
                cout << "p"<< " ";
            }
                cout << endl;
        }
    }
    
    
    void TriangleShape(int length) {  
      for (int i = 1; i <= length; i++)
        {
            sleep(1);
            for (int j = length - i; j > 0; j--)
                cout << " ";
            for (int b = 1; b <= i; b++)
                cout << "p" << " ";
                cout << endl;
        }
    }
    
    void pentagonShape(int length) {  
      TriangleShape(length);
      SqaureShape(length);
    }
};


int main()
{
    int length = 13;
    
    GenrateShape shape;
    

    shape.pentagonShape(length);
    
    return 0;
}

 

DESIGN (ALGORITHM):
On a piece of paper (or word processor), write down the algorithm, or sequence of steps, that you will
use to solve the problem. You may think of this as a “recipe” for someone else to follow. Continue to
refine your “recipe” until it is clear and deterministically solves the problem. Be sure to include the steps
for prompting for input, performing calculations, and displaying output.
You should attempt to solve the problem by hand first (using a calculator as needed) to work out what
the answer should be for a few sets of inputs.
Type these steps and calculations into a document (i.e., Word, text, or PDF) that will be submitted along
with your source code. Note that if you do any work by hand, images (such as pictures) may be used, but
they must be clear and easily readable. This document shall contain both the algorithm and any supporting
hand-calculations you used in verifying your results. 

 

Expert Solution
Check Mark
Step 1

Introduction:

Algorithm is a sequential step of any program. In algorithm there is no specific language need. We can take simple language for explaining about step-by-step instructions. With algorithm we can easily understand the flow of program.

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education