4.16 LAB: Warm up: Drawing a right triangle
I am unable to figure out this lab, please help.
This program will output a right triangle based on user specified height triangle_height and symbol triangle_char.
(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 triangle_char character.
(2) Modify the program to use a loop to output a right triangle of height triangle_height. The first line will have one user-specified character, such as % or *. Each subsequent line will have one additional user-specified character until the number in the triangle's base reaches triangle_height. Output a space after each user-specified character, including a line's last user-specified character.
Solved 1 Answer
See More Answers for FREE
Enhance your learning with StudyX
Receive support from our dedicated community users and experts
See up to 20 answers per week for free
Experience reliable customer service
The c code is given below: #include<stdio.h> #include<stdlib.h> //function for Question 1 triangle with fixed heght void RT1(int height) { int i, j, n=height; printf("The triangle isn"); for (i = 1; i <= n; ++i) { for (j = 1; j <= i; ++j) { printf("* "); } printf("n"); } } //function for Question 1 triangle with user defined heght and character void RT2(int height, char t) { int i, j, n=height; printf("The triangle isn"); for (i = 1; i <= n; ++i) { for (j = 1; j <= i; ++j) { printf("%c ",t); } printf("n"); } } //function for Question 1 void RT3(int height, char t[]) { int i, j, n=height; printf("The triangle isn"); for (i = 1; i <= n; ++i) { for (j = 1; j <= i; ++j) { printf("%c ",t[i]); } printf("n"); } } //Driver code int main(){ int height,i; char t, charArray[]="!@#$%^&* ...