Question

1.13 LAB: Input and formatted output: Right-facing arrow Given two input integers for an arrowhead and...

1.13 LAB: Input and formatted output: Right-facing arrow

Given two input integers for an arrowhead and arrow body, print a right-facing arrow.

Ex: If the input is:

0 1

the output is:

     1
     11
00000111
000001111
00000111
     11
     1

Can anyone help me with this? I was able to get the smaller arrow on Chegg but not this one. Thank You!

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

Assumptions :

  • Considering C++ as programing language as there is no information regarding programming language used.
  • Considering Second no( here it's 1), which has been given as input should be at Arrowhead.

I have written a function for drawing an arrow. The concept is very simple which could be used in any language.

CONCEPT:

From the observation of the output:

  • First, second, sixth, and seventh line has 2 spaces.
  • Third, Fourth and Fifth line has individually 5 Zeroes.

We just need to print individual lines based on these observations to get the desired output. We could simply print these things as there is no requirement of changing length of the arrow.

CODE:

#include<iostream>

using namespace std;
//function defination for drawing right facing arrow
void draw_arrow(int x, int y);
int main()
{  
   //initializing Variables
   int x,y;
   //get input
   cout<<"Enter Two Integers: \n";
   cin>>x>>y;
   //Displaying extra line at command window to get clear figure of arrow
   cout<<"\n\n\n\n";
   //Calling Function to draw arrow
   draw_arrow(x,y);
   return 0;
}

void draw_arrow(int x, int y)
{  
   //1st line -- 2 spaces and 1 second input number
   cout<<" "<<" "<<y<<endl;
   //2nd line -- 2 spaces and 2 second input number
   cout<<" "<<" "<<y<<y<<endl;
   //3rd line -- 5 first input and 3 second input number
   cout<<x<<x<<x<<x<<x<<y<<y<<y<<endl;
   //4th line -- 5 first input and 4 second input number
   cout<<x<<x<<x<<x<<x<<y<<y<<y<<y<<endl;
   //5th line -- 5 first input and 3 second input number
   cout<<x<<x<<x<<x<<x<<y<<y<<y<<endl;
   //6th line -- 2 spaces and 2 second input number
   cout<<" "<<" "<<y<<y<<endl;
   //7th line -- 2 spaces 1 second input number
   cout<<" "<<" "<<x<<endl;
}

CONSOLE OUTPUT


Add a comment
Know the answer?
Add Answer to:
1.13 LAB: Input and formatted output: Right-facing arrow Given two input integers for an arrowhead and...
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
  • Given two input integers for an arrow body and arrowhead (respectively), print a right-facing arrow. Ex:...

    Given two input integers for an arrow body and arrowhead (respectively), print a right-facing arrow. Ex: If the input is: 0 1 the output is: 1 11 00000111 000001111 00000111 11 1 #include using namespace std; int main() {    int baseChar;    int headChar;    /* Type your code here. */    return 0; }

  • Python Language Given input characters for an arrowhead and arrow body, print a right-facing arrow. Ex:...

    Python Language Given input characters for an arrowhead and arrow body, print a right-facing arrow. Ex: If the input is: * # Then the output is: # ******## ******### ******## #

  • 3.16 LAB: Output range with increment of 10 Write a program whose input is two integers,...

    3.16 LAB: Output range with increment of 10 Write a program whose input is two integers, and whose output is the first integer and subsequent increments of 10 as long as the value is less than or equal to the second integer. Ex: If the input is: -15 30 the output is: -15 -5 5 15 25 Ex: If the second integer is less than the first as in: 20 5 the output is: Second integer can't be less than...

  • Write a program whose input is two integers and whose output is the two integers swapped....

    Write a program whose input is two integers and whose output is the two integers swapped. Write in C language 7.3 LAB: Swapping variables Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the input is: 38 then the output is: 83 Your program must define and call a function. SwapValues returns the two values in swapped order. void SwapValues(int* userVali, int* userVal2) ACRIVITY 7.3.1: LAB: Swapping variables 0/10 ] main.c...

  • Write a program that first gets a list of integers from the input and adds them...

    Write a program that first gets a list of integers from the input and adds them to an array. The input begins with an integer indicating the number of integers that follow (Your program should work for any size of the array). Then, get the last value from the input, and output all integers less than or equal to that value by iterating through the array. Ex: If the input is: Enter the number of integers: 5 Enter integer 1:...

  • C++ please 27.5 Loops (nested)**: Sum a given number of integers A user will enter an...

    C++ please 27.5 Loops (nested)**: Sum a given number of integers A user will enter an initial number, followed by that number of integers. Output those integers' sum. Repeat until the initial number is O or negative. Ex: If the user enters 3 96 1 0, the output is 16 Ex: If the user enters 396125 3 0, the output is 16 Hints: Use a while loop as an outer loop. Get the user's initial number of ints before the...

  • ****Coral Please**** Given a sorted list of integers, output the middle integer. Assume the number of...

    ****Coral Please**** Given a sorted list of integers, output the middle integer. Assume the number of integers is always odd. Ex: If the input is 2 3 4 8 11 -1 (a negative indicates end), the output is: 4 The maximum number of inputs for any test case should not exceed 9. If exceeded, output "Too many inputs". Hint: Use an array of size 9. First read the data into an array. Then, based on the number of items, find...

  • 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...

  • 8.10 LAB: Middle item Given a set of data, output the middle item (if even number...

    8.10 LAB: Middle item Given a set of data, output the middle item (if even number of items, output the two middle items). Assume that the data set will always contain less than 20 items. Ex: If the input is 579 11 13-1 (a negative indicates end), the output is: Ex: If the input is 57 911-1, the output is: 7 9 Hint: First read the data into an array. Then, based on the array's size, find the middle item(s)...

  • Statement Given two non-zero integers, print "YES" if exactly one of them is positive and print...

    Statement Given two non-zero integers, print "YES" if exactly one of them is positive and print "NO" otherwise Hint: You will need to use the following logical operators: and or Example input #1 -5 10 Example output #1 YES Example input#2 1 9:36 AM 10/1/2020 end og up delete home "brt so + backspace num lock 11 9

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