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 rock band apologized for automatically adding its new album to every iPhone 6 in 2014
Naya [18.7K]
Hey there!
This was done by the band U2.
It's actually gotten quite annoying, and it's yet to be removed.
Hope this helps!
8 0
3 years ago
Read 2 more answers
Consider the class Money declared below. Write the member functions declared below and the definition of the overloaded +. Modif
disa [49]

Answer: Provided in the explanation section

Explanation:

#include<iostream>

using namespace std;

class Money{

  private:

      int all_cents;

  public:

      Money();

      double get_value() const;

      Money(int,int);

      void printamount();

      friend Money operator+(const Money&, const Money&);

      friend ostream& operator<<(ostream&, const Money&);

      friend istream& operator>>(istream&, Money&);

};

Money::Money(){all_cents=0;}

double Money::get_value() const{return all_cents/100.0;}

Money::Money(int dollar ,int cents){

  all_cents = dollar*100+cents;

}

void Money::printamount(){

  cout<<"$"<<get_value()<<endl;

}

Money operator+(const Money& m1, const Money& m2){

  int total_cents = m1.all_cents + m2.all_cents;

  int dollars = total_cents/100;

  total_cents %=100;

  return Money(dollars,total_cents);

}

ostream& operator<<(ostream& out, const Money& m1){

  out<<"$"<<m1.get_value()<<endl;

  return out;

}

istream& operator>>(istream& input, Money& m1){

  input>>m1.all_cents;

  return input;

}

int main(){

 

  Money m1;

  cout<<"Enter total cents: ";

  cin>>m1;

  cout<<"Total Amount: "<<m1;

 

  Money m2 = Money(5,60);

  Money m3 = Money(4,60);

  cout<<"m2 = ";m2.printamount();

  cout<<"m3 = ";m3.printamount();

  Money sum = m2+m3;

  cout<<"sum = "<<sum;

 

}

cheers i hope this helped !!

5 0
3 years ago
Your friends know that you understand a lot about computers, both the technical details of how they operate as well as informati
erma4kov [3.2K]

Answer:

The answer is A.

Explanation:

Regarding the information given in the question, we are asked to evaluate the options given which i believe have answers as follows;

B is true. Public-domain means that there are no individuals who hold a copyright over the subject which enables people to copy and distribute, the software in this case, freely.

C is true. Shareware is a term that is used for applications which have a certain trial period for users to decide whether the application meets their needs and demands and then they have to pay the required amount to keep using the software to its full potential. Most often it is the case that if the user does not agree to a payment, the features they are allowed to use are very limited and render the software almost useless until the payment is completed.

D is true. "Copyright" is by definition is approved by the authorities and gives its creater the right to use, sell and change the creative product as they please. It works the same way for software products as well so the statement in option D is true.

A is wrong. Although they are freeware, this softwares still may have copyrights and even if they do not, they are very basic or even incomplete programs to satisfy the minimal needs of its users.

I hope this answer helps.

7 0
3 years ago
FOLLOW INSTRUCTIONS BELOW , WRITTEN IN JAVA LANGUAGE PLEASE AND THANK YOU !
boyakko [2]
It’s a lot of reading sorry can’t help you but try your best too
7 0
3 years ago
What is the engine for<br> ?
alexira [117]

<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3

Answer:

An engine or motor is a machine designed to convert one form of energy into mechanical energy. Heat engines convert heat into work via various thermodynamic processes.

<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3

8 0
3 years ago
Read 2 more answers
Other questions:
  • In dt.py, you will implement a basic decision tree classifier for
    5·1 answer
  • Trish uas bought a new computer, which she plans to start working on aftwr a week. Since Trish has not used computers in the pas
    13·1 answer
  • What is a main cause of a virus on a computer
    6·1 answer
  • Which command is used to combine two or more cells together into one cell?
    14·2 answers
  • [Java] Using the comparable interface
    13·1 answer
  • The major difference between a template and another document is in _____.
    7·1 answer
  • Which browser should you choose if you want all viewing information except thumbnail previews of websites?
    15·2 answers
  • What is a Software that interprets commands drom the keyboard and mouse
    13·1 answer
  • How can the system administrator give the executive assistant the ability to view, edit, and transfer ownership of all records,
    6·1 answer
  • Impromptu speaking ability is very important in the workplace to clearly and effectively communicate ideas. An effective impromp
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!