Question

(In C++) The program will output a right triangle based on user specified height triangleHeight and...

(In C++) The program will output a right triangle based on user specified height triangleHeight and symbol triangleChar.
Modify the program to use a nested loop to output a right triangle of height triangleHeight. The 1st line will have one user-specified character, such as %or * Each subsequent line will have 1 additional user-specified character until the number in the triangle"s base reaches triangleHeight. Output a space after each user-specified character, including after the line"s last user-specified character.
Example output for triangkeChar=% and triangleHeight=5:

This program will output a right triangle based on user specified height triangleHeight and synbol triangleChar.
The given program outputs a fixed-height triangle using a * character. Modify the given program to output a right triangle that instead uses the user- specified triangleChar character.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

If you have any doubts, please give me comment...

#include<iostream>

using namespace std;

int main(){

int triangleHeight;

char triangleChar;

cout<<"Enter triangle height: ";

cin>>triangleHeight;

cout<<"Enter triangle character: ";

cin>>triangleChar;

for(int i=0; i<triangleHeight; i++){

for(int j=0; j<=i; j++){

cout<<triangleChar;

}

cout<<endl;

}

return 0;

}

nagarajuanagaraju-Vostro-3550:27012020$ g++ triangle.cpp nagarajuanagaraju-Vostro-3550:27012020$ ./a.out Enter triangle heigh

Add a comment
Know the answer?
Add Answer to:
(In C++) The program will output a right triangle based on user specified height triangleHeight 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
  • In C programming language: This program will output a right triangle based on user specified height...

    In C programming language: This program will output a right triangle based on user specified height triangleHeight and symbol triangleChar. (1) The given program outputs a fixed-height triangle using a * character. Modify the given program to output a right triangle that instead uses the user-specified triangleChar character. (1 pt) (2) Modify the program to use a nested loop to output a right triangle of height triangleHeight. The first line will have one user-specified character, such as % or *....

  • in Java This program will output a right triangle based on user specified height triangleHeight and...

    in Java This program will output a right triangle based on user specified height triangleHeight and symbol triangleChar. (1) The given program outputs a fixed-height triangle using a character. Modify the given program to output a right triangle that instead uses the user-specified trianglechar character. (1 pt) (2) Modify the program to use a nested loop to output a right triangle of height triangleHeight. The first line will have one user-specified character, such as % or* Each subsequent line will...

  • Hello there, im trying to answer this question in c 4.22 LAB: Warm up: Drawing a...

    Hello there, im trying to answer this question in c 4.22 LAB: Warm up: Drawing a right triangle This program will output a right triangle based on user specified height triangleHeight and symbol triangleChar. (1) The given program outputs a fixed-height triangle using a * character. Modify the given program to output a right triangle that instead uses the user-specified triangleChar character. (1 pt) (2) Modify the program to use a nested loop to output a right triangle of height...

  • Write a Python function make_triangle(trianglechar, triangleheight) that will return a string with an isosceles right triangle...

    Write a Python function make_triangle(trianglechar, triangleheight) that will return a string with an isosceles right triangle based on the two formal parameters triangle_height giving the triangle height and triangle_char that gives the symbol to be printed. Important notes: This program returns (not prints!) a string. For this function and the other part of this lab you are required to put in a docstring. That will be checked by a TA/grader reading the program. Every one of the occurrences of triangle_char...

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

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

  • white a program that determines if 3 numbers that are entered, by the user, are sides of a right triangle.

     project 5 functions calling functions white a program that determines if 3 numbers that are entered, by the user, are sides of a right triangle. remember any combination of numbers can be entered, 3 4 5, 5 4 3, 4 3 5... are all the same right triangle. you must have a function that does exponentiation, one that does input one that does output. and one that does the comparisons the main will be this code main:    jal allwork    li $v0,10    syscall function allwork will...

  • Write a C program named space_to_line.c that features a while loop that continuously reads input from...

    Write a C program named space_to_line.c that features a while loop that continuously reads input from the user one character at a time and then prints that character out. The exception is that if the user inputs a space character (ā€˜ ā€˜), then a newline character (ā€˜\nā€™) should be printed instead. This will format the output such that every word the user inputs is on its own line. Other than changing the spaces to newlines, the output should exactly match...

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

  • Please solve in C++ Pascal's Triangle Videos [edit] write a C++ that asks the user to...

    Please solve in C++ Pascal's Triangle Videos [edit] write a C++ that asks the user to enter the number of rows (N) and then prints the first N rows of Pascal's Triangle, che row per line. Your program should echo print N. Good News [edit] The best way to construct Pascal's Triangle is to use a nested loop with repeated calls to the combination already written for a previous programming assignment, Just #include "myFunctions.h" and use the combination function from...

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
ADVERTISEMENT