A code to draw a certain number of triangle without using arrays.

Write a code to draw a certain number of triangle without using arrays.

Program Specifications5.1 Part 1Part 1 (pa2a.c) is a simple program that displays triangle patterns side-by-side using nested while loops.The goal of the program is to read in a number from the user and then generate four side by side triangles based on the size entered by the user.

Make sure your prompt and output messages exactly match the sample prompts and messages word-for-word.Use scanf() to read inputAllow the user to input the number of rows defining the size of the side-by-side triangles.No hardcoding or magic numbers in your code.Each loop must be based on the current row number/iteration of the outermost loop.Hint: Treat each of the four triangle patterns as its own set of nested loops. Each row of each triangle pattern is made up of some number of individual ‘‘ and ‘ ‘ (space) chars. Note: there is a space character between adjacent triangles. To get a better understanding, if size of the triangle is 5, here’s the spacing (represented in a grid, for a clearer picture of the individual ‘‘ and ‘ ‘ characters).*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

All asterisks (‘*’) and spaces (‘ ‘) must be printed as a single character at a time using the provided printStar() or printSpace() methods controlled by the nested while loops.The printNewLine() method is also provided for you to print the newline at the end of each row.No strings!You are not allowed to use a string or array or any data structure to build each line of the output.Formatting is important for this program. If your output does not match the required output character-for-character, no credit will be awarded. Note there is no space at the end of each line.Only valid integers will be entered, but you must check for integers less than 2 and report the exact error message as shown in the example below.5.1.1 GETTING STARTEDThe pa2a.c starter code for this program has a series of comments to help you. Use the comments as a TODO list and complete each section. It’s highly recommended that you complete each section and make sure it compiles and runs before moving on to the next section.

The following list gives more details about the commented sections in the starter code.

1) Define any constant definitions before the main() method. Use #define, a descriptive name in all caps with words separated by underscores, and a number (or letter) to create the constant.

Example:

define PRICE_OF_BURGER 3.99

2) Define local variables at the start of main()

It’s good practice, especially in the beginning, to define all of your local variables at the start of the main() method. This is a common practice to help keep you organized.

You will want a local variable for the user input as well as for the integers used to control the while loops.

3) Ask the user to enter the size of the triangles to display using scanf(). Make sure to check the value entered by the user and if it is less than 2, print out the proper error message, then loop and ask the user to enter the size again.

4) Before you start printing out the triangle, add an extra new line so that your output matches the sample output.

5) Start the outer while loop. Make sure to initialize any variables you need in the condition beforehand.

6) Inside the outer while loop, use a set of nested while loops to print out the next part of the first triangle. Since the triangles are being drawn line by line, you only need to print out the stars and spaces for the first triangle for one line. Use the printStars() and printSpace() methods that were provided in the starter code to print out the proper text.

Note: you will need to do this twice, once for the stars and once for the spaces to complete the triangle. After you complete the triangle, add a space before starting the next triangle.

Hint: the key is to use the counters for the outer and inner loops to determine how many stars and how many spaces to print for a triangle for the current line.

7) Inside the outer while loop, use a set of nested while loops to print out the next part of the second triangle. This is just like #6 above, but in a different pattern.

8) Inside the outer while loop, use a set of nested while loops to print out the next part of the third triangle. This is just like #6 above, but in a different pattern.

9) Inside the outer while loop, use a set of nested while loops to print out the next part of the fourth triangle. This is just like #6 above, but in a different pattern.

Note: after you complete the fourth triangle, do not print out a space.

10) Before looping to the next line, add a newline and increment any counters the outer loop needs to keep going.

5.1.2 SAMPLE OUTPUTExample Executions (user input in BOLD):

Example 1:

Enter the size of the triangles to display: 12

Example 2:

Enter the size of the triangles to display: -1

Triangle size must be > 1; Try again.

Enter the size of the triangles to display: 0

Triangle size must be > 1; Try again.

Enter the size of the triangles to display: 5

Example 3:

Enter the size of the triangles to display: 2

5.1.3 TESTING YOUR PROGRAMTo grade your program, we will be comparing the output of your code by comparing it against the output of our code. If your code does not match our output, we will not be able to grade your assignment and you will receive a score of 0!

In order to help you determine whether the output of your code will match ours, we have provided several reference solutions. Compare your output with the reference files carefully to ensure your code will pass our test cases.

You can download all the references files from the same location as the starter code. Make sure to download the reference files to the same folder as your source code. This will make running the tests easier.

YOU DO NOT WANT TO MODIFY THE REFERENCE FILES!

Also note that the reference files are just to make sure our tester can read your output. The reference files are not our test cases.

Attend discussion (or review the discussion recording) to see tools on comparing the results.

AUTO-MATCH IS ACTIVEThis question is set to Auto Match. If you place a bid that matches the Time and Price; you will be assigned to this question within 10 min.PRIORITISED TUTORS

YOUR STATISTICStag_faces75%

assignment_turned_in6

assignment_late1

alarm_off0

monetization_on15%

New Student(15% commission rate)To make sure new students have a great experience on Studypool, your service and answer quality will be held to the highest standard.Because of this, this question has a reduced commission rate (15%). Working with new students successfully also increases your chances of earning the Ambassador badge.PRICE

cachedCALCULATORDELIVERY TIME

Sample Solution
The post A code to draw a certain number of triangle without using arrays.

Image result for Order Now images

CLICK HERE TO ORDER NOW!!

Leave a Reply

Your email address will not be published. Required fields are marked *