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
Wouldn’t it be nice if whenever we messed up our life we could simply press ‘Ctrl Alt Delete’ and start all over?
Orlov [11]
Sure, if you want to delete things
8 0
4 years ago
Read 2 more answers
Network access control authenticates users logging into the network and determines what data they can access and actions they ca
erik [133]

Answer:

The answer is letter A

Explanation:

The statement is TRUE

3 0
4 years ago
HELP!!!
jeyben [28]

Answer:

A. a tool tip

Explanation:

6 0
3 years ago
Read 2 more answers
when happens when the quantity of a good supplied at a given price is greater than the quantity demanded
Norma-Jean [14]

If there is a bigger supply than demand, it is called a surplus.

8 0
3 years ago
Read 2 more answers
A company is inviting design for its new corporate logo from its users. This is an example of ? A. Crowdfunding B. Crowdvoting C
adoni [48]

a crown Source because is beautiful in its own way and it'll be a nice company because you can own the company in a beautiful way now will people wakes blow and now there is not a company that's named the same thing and over and over again

6 0
3 years ago
Read 2 more answers
Other questions:
  • What are some good editing software apps for pc?
    11·1 answer
  • Consider the following code snippet.a.File inputFile = new File("dataIn.txt");b.Scanner in = new Scanner(inputFile);c.while (in.
    7·1 answer
  • In c++
    9·1 answer
  • Ergonomia este știința care studiază ....
    6·1 answer
  • TCP is a Transport-layer protocol used to communicate between applications, but it's a lightweight Transport-layer protocol, mea
    10·1 answer
  • Scenes for films are almost always filmed in the same sequence they appear in the script.
    14·1 answer
  • https://brainly.com/question/10197478#:~:text=Option%20A%20is%20the%20correct,in%20return%20of%20their%20money.
    13·1 answer
  • As you are designing a site for a client, you notice that the bulleted lists do not appear when a blog is published. You look in
    6·1 answer
  • Consider this binary search tree:______.
    12·1 answer
  • What sets Web pages apart from other documents is that they contain a special kind of text called ___, which is document text th
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!