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
Crazy boy [7]
4 years ago
14

Write a program that asks the user to enter the size of a triangle (an integer from 1 to 50). Display the triangle by writing li

nes of asterisks. The first line will have one asterisk, the next two, and so on, with each line having one more asterisk than the previous line, up to the number entered by the user. On the next line write one fewer asterisk and continue by decreasing the number of asterisks by 1 for each successive line until only one asterisk is printed.
Computers and Technology
1 answer:
lianna [129]4 years ago
7 0

Answer:

/*

* Program to print traingle using asterisk.

*/

#include<iostream>

using  namespace std;

//Function to print n asterisk in a row.

void printAsterisk(int n)

{

   for(int i = 0;i<n;i++)

   cout<<"*";

}

int main()

{

//Variable to store size of trianle

int size;

cout<<"Enter the size of triangle"<<endl;

cin>>size;

//print asterik in increasing order line by line.

for(int i =0; i<size;i++)

{

    printAsterisk(i);

    cout<<endl;

}

//print asterik in decresing order line by line.

for(int i =size-1; i>0;i--)

{

    printAsterisk(i-1);

    cout<<endl;

}

 

 

}

Output:

Enter the size of triangle

10

*

**

***

****

*****

******

*******

********

*********

********

*******

******

*****

****

***

**

*

Explanation:

Since no programming language is mentioned therefore answer is provided in C++.

The above program will use two for loops to print the triangle using asterisk.

The first loop will print the asterisk line by line with each line having one more asterisk than the previous one till the size of the triangle.

The second for loop will print the asterisk using same logic as above but in reverse order.

Final output of triangle will be obtained.

You might be interested in
Imagine that you are helping a customer needing technical assistance for a printer they recently purchased. They bought the prin
hodyreva [135]
1. Ask if the printer is plugged in
2. Try a different power cord.
3. If none of the other thing work try a return using the warranty. 
7 0
3 years ago
Storage system that uses lasers to read data
tatuchka [14]

I believe it is an optical storage system that uses lasers to read data.

5 0
4 years ago
Read 2 more answers
a uniform density sheet of metal is cut into a shape of an isosceles triangle, which is oriented with the base at the bottom and
Cloud [144]

The horizontal center of mass will be located at the horizontal center of mass will be located on the center line. This is further explained below.

<h3>What is Location?</h3>

Generally, a location or place that is inhabited, open for occupation or distinguished by some distinctive feature: situation The setting of the property contributes significantly to its overall allure.

In conclusion, The center line will serve as the location for the horizontal center of mass, which will be found at the same location as the center line.

Read more about Location

brainly.com/question/11718756

#SPJ1

6 0
2 years ago
Programa que previene, detecta y elimina virus informáticos.
vesna_86 [32]

Answer:

Software antivirus

Explanation:

6 0
3 years ago
The physical parts or components of a computer system is called .
dmitriy555 [2]
Answer:
Motherboard

Explanation:
Motherboard is the main component of a computer. It connects with other parts of the computer including drive disks, RAM and CPU and any other expansion slots :)

(Hope it helped)
4 0
3 years ago
Other questions:
  • Look at the following array definition:
    11·1 answer
  • A computer is a(n) ____ device, operating under the control of instructions stored in its own memory, that can accept data, proc
    9·1 answer
  • What command should you use to rearrange parts of files on the drive so they are contiguous?
    5·1 answer
  • What should a system administrator use to disable access to a custom application for a group of users?
    5·1 answer
  • (Display nonduplicate words in ascending order)
    11·1 answer
  • The network team has well established procedures to follow for creating new rules on the firewall. This includes having approval
    15·1 answer
  • Charli D'amelio bought her followers. <br><br> True or true? ;)​
    15·2 answers
  • Computer science is a blank process
    6·2 answers
  • You have been asked to replace a cracked screen on a laptop. The replacement screen was delivered today, but it did not include
    7·1 answer
  • A pointing device used mainly for computer games is known as
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!