1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
timofeeve [1]
3 years ago
14

This program will output a right triangle based on user specified height triangleHeight and symbol triangleChar. (1) The given p

rogram 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 have one 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. (2 pts) Example output for triangleChar = % and triangleHeight = 5: Enter a character: % Enter triangle height: 5 % % % % % % % % % % % % % % % LAB ACTIVITY 4.15.1: Ch 4 Warm up: Drawing a right triangle (C)
#include

int main(void) {
char triangleChar;
int triangleHeight;

printf("Enter a character:\n");
scanf("%c", &triangleChar);

printf("Enter triangle height:\n");
scanf("%d", &triangleHeight);
printf("\n");

//you solution here
return 0;
}
Computers and Technology
1 answer:
vesna_86 [32]3 years ago
5 0

Answer:

#include <stdio.h>

int main(void) {

   char triangleChar;

   int triangleHeight;

   printf("Enter a character:\n");

   scanf(" %c", &triangleChar);

   printf("Enter triangle height:\n");

   scanf("%d", &triangleHeight);

   printf("\n");

   int i, j;

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

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

           printf("%c ", triangleChar);

       }

       printf("\n");

   }

   return 0;

}

Explanation:

  • Get the character and height as an input from user.
  • Run the outer loop up to the height of triangle.
  • Run the inner loop up to the value of i variable and then display the character inside this loop.
You might be interested in
Write a function call using the ebay_fee() function to determine the fee for a selling price of 15.23, storing the result in a v
Sholpan [36]

Answer:

my_fee = ebay_fee(15.23)

Explanation:

Functions are sections of a program that provide a particular outlined procedure, we call a function by writing its name followed by a pair of parenthesis, the function may be designed in a way that it accepts arguments while been called, Like the case of the ebay_fee(15.23). the number within the pair of parenthesis id the argument, and it is the data that the functions will process and return a value afterwards.

7 0
4 years ago
A type of graph that uses horizontal bars to compare data is called a
sergiy2304 [10]
The answer is A) a bar graph

6 0
4 years ago
Read 2 more answers
Lesson 1 (4.0 points)
sesenic [268]


3. Hold down the CTRL, ALT, and DELETE keys simultaneously, click Task Manager option, then right-click the frozen program's name, and finally click the end task button.


8 0
3 years ago
Read 2 more answers
Write a class named Accumulator containing: An instance variable named sum of type integer. A constructor that accepts an intege
Genrish500 [490]

Answer:

The following are the code in the C++ Programming Language.

//define header file

#include <iostream>

// using namespace

using namespace std;

//define a class

class Accumulator

{

//set private access modifier

private:  

//declare integer type variable

int sum;

//set public access modifier

public:

//define constructor  

Accumulator (int sum)

{

//refer the same class as instance variable

this->sum = sum;

}

//define integer type function

int getSum()

{

//return the value of sum

return sum;

}

//define void type function

void add (int value)

{

//variable sum is increased by the argument value

sum += value;

}

};

Explanation:

<u>The following are the description of the code</u>.

  • Firstly, set the required header file and namespace then, define a class 'Accumulator' and inside the class.
  • Set private access modifier then, declare an integer data type variable 'sum'.
  • Declare a class constructor whose name is the same as the class name 'Accumulator()' and pass integer data type argument 'sum' in its parameter that refers to the same class as instance variable.
  • Define a integer data type function 'getSum()' that return the value of the variable sum.
  • Finally, define a void type function 'add()' and pass the integer data type argument 'value' in its parameter in which the variable sum is increased by the argument value .
4 0
4 years ago
When initiating a connection how does tcp establish a connection?
Pani-rosa [81]
It uses a 3-way handshake

1. SYN from client to server.
2. SYN-ACK from server to client.
3. ACK from client to the server.

At this point, both client and server have received an acknowledgement of the connection.

4 0
3 years ago
Other questions:
  • program that reads numbers from scanf (keyboard) and then sums them, stopping when 0 has been entered. Construct three versions
    14·1 answer
  • In this assignment you will write a function that will calculate parallel resistance for up to 10 parallel resistors. Call the f
    12·1 answer
  • How auto insurance companies manage risk?
    12·1 answer
  • On what basis can you categorize the generations of computers?
    11·1 answer
  • One reason to move to a paperless society is that printers are becoming prohibitively expensive true or false
    13·2 answers
  • Learning how to use word processing and spreadsheets, and creating presentations are all considered __________ computer skills.
    15·2 answers
  • Julio receives many emails from a healthcare site. He finds them useful, and he wants to save them all in a folder. How can he a
    12·1 answer
  • Select the correct answer.
    12·1 answer
  • For things like school, you should have a more serious:
    11·1 answer
  • Discuss the role of the concept behind the "Internet of Things (IoT)" in today's digitally connected society.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!