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
Which term refers to actions that you would typically perform on a computer to revive it if it functions in an unexpected manner
andriy [413]
There are many answers to this question. The first step is normally a reboot, second, I would check witch task or service is taking up all the CPU cycles and check the system and error logs. The list goes on... I'm not sure how detailed you want to get.
5 0
3 years ago
Read 2 more answers
What changes has Sue made so far? Check all that apply.
Alexus [3.1K]

Answer:

Its C, E, and F

Explanation:

On edg

8 0
3 years ago
Read 2 more answers
Java provides a number of interfaces and classes to systematically implement collections.
solmaris [256]

Answer:

A) True

Explanation:

Java provides collections architecture or framework used to store and manipulate a group of objects or collections.

The collection framework has interfaces which include; Set, Queue, Deque, List, as well as classes which include; Hashset, ArrayList, LinkedList, LinkedHashset, PriorityQueue, Vector and TreeSet.

There are also many methods declared in the collection interface which include; add(), addAll(), remove(), removeAll(),retainAll(), clear(), size(), iterator(), toArray() etc

4 0
3 years ago
What is a variable in programming?
HACTEHA [7]
A symbol or set of characters in a programming statement whose value can be changed
3 0
3 years ago
WILL GIVE BRAINLIEST!!!!!!!!!
sukhopar [10]

Answer:

True

Explanation:

7 0
3 years ago
Other questions:
  • A size of a jumbo candy bar with rectangular shape is l x w x h. Due to rising costs of cocoa, the volume of the candy bar is to
    9·1 answer
  • A large IPv4 datagram is fragmented into 4 fragments at router 1 to pass over a network with an MTU of 1500 bytes. Assume each f
    15·1 answer
  • Describe the best way to deal with a difficult co-worker?
    13·2 answers
  • In a meeting, Juan hears someone say a product mix is "wide." What does
    13·1 answer
  • Write a function named change() that has an integer parameter and six integers reference parameters named hundreds, fifties, twe
    7·1 answer
  • '|'/2`/ '|'[] |)[-([]|)[- '|'#!$
    9·1 answer
  • How do u delete a post on brainly
    7·1 answer
  • In this exercise, you will write a class that represents how you spend your time during the week The class should have four doub
    6·1 answer
  • What is the importance of knowing the concept of programming?
    8·1 answer
  • Which is true for comments? Group of answer choices The compiler does not generate machine code for comments. The compiler conve
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!