Question

4.30 Draw a Custom Full Arrow This program outputs an upwards facing arrow composed of a...

4.30 Draw a Custom Full Arrow

This program outputs an upwards facing arrow composed of a rectangle and a triangle. The arrow characters used to draw the base and head are characters specified by the user. The dimensions are defined by user as well, specified as arrow base height, arrow base width, and arrow head width.

Create a program to output an arrow that reads in the respective characters and values in a java format. Perform sanity checking on numeric inputs, e.g., accept an arrow head width that is equal or larger than the arrow base width. Use a loop to continue prompting the user for an arrow head width until the value is correct. Don't forget to comment your code!: Example:

Enter a character for the base:
|
Enter arrow base height:
3
Enter odd arrow base width:
3
Enter a character for the head:
*
Enter odd arrow head width:
3

 *
***
|||
|||
|||
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi,

Please go through code and output.

CODE:

#include <stdio.h>


int main()

{

int height=0, width=0, headWidth=0;

char base, head;

int i=0,j=0;

/* take data from user */

printf("Enter a character for the base: \n");

scanf("%c",&base);

HIGHT:

printf("Enter arrow base height: \n");

scanf("%d",&height);

if(height <= 0)

{

printf("Value is worng\n");

goto HIGHT;

}

WIDTH:

printf("Enter odd arrow base width:\n");

scanf("%d",&width);

if(width <= 0)

{

printf("Value is worng\n");

goto WIDTH;

}

printf("Enter a character for the head: \n");

scanf(" %c",&head);

HEADWIDTH:

printf("Enter odd arrow head width: \n");

scanf("%d",&headWidth);

if(headWidth <= 0 || headWidth%3 !=0)

{

printf("Value is worng\n");

goto HEADWIDTH;

}

/* print head */

printf(" *");

for(i=0; i<=headWidth; i=i*3)

{

for(j=i;j>0; j--)

{

printf("%c",head);

}

printf("\n");

i++;

}

/*print base */

for(i=0; i<height; i++)

{

for(j=0; j<width; j++)

printf("%c",base);

printf("\n");

}

}

OUTPUT;

Enter a character for the base: Enter arrow base height: Enter odd arrow base width: Enter a character for the head: Enter od

Add a comment
Know the answer?
Add Answer to:
4.30 Draw a Custom Full Arrow This program outputs an upwards facing arrow composed of a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The...

    This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by user specified arrow base height, arrow base width, and arrow head width. (1) Modify the given program to use a loop to output an arrow base of height arrowBaseHeight. (1 pt) (2) Modify the given program to use a loop to output an arrow base of width arrowBaseWidth. Use a nested loop in which the inner loop draws the...

  • 5.13 Program: Drawing a half arrow (Python 3) This zyLab activity is the traditional programming assignment,...

    5.13 Program: Drawing a half arrow (Python 3) This zyLab activity is the traditional programming assignment, typically requiring a few hours over a week. The previous section provides warm up exercises intended to help a student prepare for this programming assignment. This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by user specified arrow base height, arrow base width, and arrow head width. (1) Modify the given program to...

  • Program: Drawing a half arrow (Java) Instructor note: While you will be submitting this assignment through Zybooks, make...

    Program: Drawing a half arrow (Java) Instructor note: While you will be submitting this assignment through Zybooks, make sure you are still applying appropriate formatting and in-line commenting. This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by user specified arrow base height, arrow base width, and arrow head width. (1) Modify the given program to use a loop to output an arrow base of height arrowBaseHeight. (1 pt)...

  • 1. You are given a C file which contains a partially completed program. Follow the instructions...

    1. You are given a C file which contains a partially completed program. Follow the instructions contained in comments and complete the required functions. You will be rewriting four functions from HW03 (initializeStrings, printStrings, encryptStrings, decryptStrings) using only pointer operations instead of using array operations. In addition to this, you will be writing two new functions (printReversedString, isValidPassword). You should not be using any array operations in any of functions for this assignment. You may use only the strlen() function...

  • Edit a C program based on the surface code(which is after the question's instruction.) that will...

    Edit a C program based on the surface code(which is after the question's instruction.) that will implement a customer waiting list that might be used by a restaurant. Use the base code to finish the project. When people want to be seated in the restaurant, they give their name and group size to the host/hostess and then wait until those in front of them have been seated. The program must use a linked list to implement the queue-like data structure....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT