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]
3 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]3 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
Select the images that are isometric drawings
valkas [14]

Answer:

There’s no images

Explanation:

7 0
2 years ago
What are the letter that go under each note?
gladu [14]

Answer:

A, B, C, D, E, F, G pls mark me brainliest see explanation below

Explanation:

those are the letters if you search up letters for music you can find them way easier than me explaining and you will also learn faster. please mark me brainliest

5 0
2 years ago
Read 2 more answers
Several users on the second floor of your company's building are reporting that the network is down. you go to the second floor
Svetllana [295]

Answer:

Question users

Explanation:

Q:

Several users on the second floor of your company's building are reporting that the network …

A. Establish a plan of action

B. Question users...

A:

B. Question users

8 0
2 years ago
Which three are functions of the operating system?
Stels [109]

Answer:

An operating system has three main functions: (1) manage the computer's resources, such as the central processing unit, memory, disk drives, and printers, (2) establish a user interface, and (3) execute and provide services for applications software.

7 0
3 years ago
Read 2 more answers
2 ejemplos de sistemas automáticos en la construcción civil.
vodomira [7]

Answer:

ncdjjgcdbywgf ebyafbhfgcabfy bahgfdhvgafvhaef aeyhyfbhavgcjhvvhgfrau ahkgvbha,vjykabvfbhagkfvbadh avhvhav havgkv fa64gfdvwhefv nsdagcyudaf vdabncvyaukefk we7ytryuhaqgryw4tgty gyut r uytr eyuguhjayuft47rgutr7ytr  yuwqGHRUEGW7RUGU4GQATYUERGAYFUGEURGAAQ

Explanation:

8 0
2 years ago
Other questions:
  • When a formula contains the address of a cell, it is called a(n)
    9·1 answer
  • What does the headgear of a mine do
    6·2 answers
  • Given the code segment below, complete the assignments as stated in the comments. struct aaa { int m; int nn; } struct bbb{ stru
    13·1 answer
  • In excel, which symbol means not equal to when comparing two values?
    15·1 answer
  • Which type of microscope can only be used to view non-living specimens?
    10·2 answers
  • How many pieces are there in a normal laptop??? Good luck and solve carefully
    9·1 answer
  • Describe the difference between the while loop and the do-while loop.
    7·1 answer
  • Which of the following is equivalent to (p&gt;=q)? <br> i) P q iv) !p Where are genius people?:)
    6·1 answer
  • Are used in the Excel application to create calculations
    5·2 answers
  • How can we search person in brainly for sending request of friend
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!