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
RSB [31]
3 years ago
15

Write a CPP program that prompts the user to enter the number of lines and generates the following pattern of stars. If the nonn

egative integer is 4, then the pattern generated is:
****
***
**
*
*
**
***
****
Also, write a program that prompts the user to enter the number of lines in the pattern and uses the recursive function to generate the pattern. For example, specifying 4 as the number of lines generates the above pattern.

main.cpp

#include
using namespace std;

void printStars(int lines);

int main()
{
// prompt the user to enter a number

// call printStars

return 0;
}

void printStars(int lines)
{
// write your star pattern function here
}
Engineering
1 answer:
WINSTONCH [101]3 years ago
3 0

Answer:

Without Recursives

// Program is written using C++

// Comments are used for explanatory purpose

int main()

{

// Declare integer number, n

int n;

cout<<"Enter number of starts to print"

cin>>n;

// Iterate through to print * pattern

for(i=n; i>0;i--)

{

for(j=n; i>j-1;j--)

{

cout<<"*";

}

cout<"\n";

}

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

{

for(j=0;j<=i;j++)

{

cout<<"*";;

}

cout<"\n";

}

return 0;

}

Using Recursive

#include <iostream>

using namespace std;

void printStars(int lines);

int main()

{

// prompt the user to enter a number

int lines;

cin>> lines;

printStars(int lines);

return 0;

}

void printStars(int lines)

{

if (lines < 1)

return;

// to print the stars of a particular row

if (i <= lines)

{

cout << "* ";

// recursively print rest of the stars

// of the row

printPatternRecur(lines, i + 1);

}

else

{

// change line

cout << endl;

// print stars

printPatternRecur(lines-1, 1);

}

}

You might be interested in
Write torsion equation and explain the importance of each components.<br>​
Elanso [62]
The equations are based on the following assumptions

1) The bar is straight and of uniform section
2) The material of the bar is has uniform properties.
3) The only loading is the applied torque which is applied normal to the axis of the bar.
4) The bar is stressed within its elastic limit.

Nomenclature

T = torque (Nm)
l = length of bar (m)
J = Polar moment of inertia.(Circular Sections) ( m^4)
J' = Polar moment of inertia.(Non circluar sections) ( m^4 )
K = Factor replacing J for non-circular sections.( m^4)
r = radial distance of point from center of section (m)
ro = radius of section OD (m)
τ = shear stress (N/m^2)
G Modulus of rigidity (N/m^2)
θ = angle of twist (radians)

4 0
3 years ago
Technician A says that the carpet padding is designed to help reduce noise and vibrations.
Firdavs [7]

Answer:

Technicians A is right for the answer

4 0
3 years ago
When do you know if you start volly ball
igomit [66]
Answer You ask your coach
7 0
3 years ago
What is the purpose of gears?
Brrunno [24]

Answer:

To help wheels move in a circle

Explanation:

6 0
3 years ago
Refrigerant 134a enters an air conditioner compressor at 4 bar, 20 C, and is compressed at steady state to 12 bar, 80 C. The vol
sleet_krkn [62]

Answer:

Q=15.7Kw

Explanation:

From the question we are told that:

Initial Pressure P_1=4bar

Initial Temperature T_1=20 C

Final Pressure  P_2=12 bar

Final Temperature T_2=80C

Work Output W= 60 kJ/kg

Generally Specific Energy from table is

At initial state

 P_1=4bar \& T_1=20 C

 E_1=262.96KJ/Kg

With

Specific Volume V'=0.05397m^3/kg

At Final state

 P_2=12 bar \& P_2=80C

 E_1=310.24KJ/Kg

Generally the equation for The Process is mathematically given by

 m_1E_1+w=m_2E_2+Q

Assuming Mass to be Equal

 m_1=m_1

Where

 m=\frac{V}{V'}

 m=frac{0.06666}{V'=0.05397m^3/kg}

 m=1.24

Therefore

 1.24*262.96+60)=1.24*310.24+Q

 Q=15.7Kw

4 0
3 years ago
Other questions:
  • In Victorious, when everyone was trapped in the RV, who wasn’t? And what were they doing??
    10·1 answer
  • ¿Por qué creen que la Ingeniería Metalúrgica es una carrera estratégica para el desarrollo de nuestro país?
    9·1 answer
  • An electronic device dissipating 25 W has a mass of 20 g and a specific heat of 850 J/kg·0K. The device is lightly used, and it
    9·1 answer
  • Ame:<br> 7. A step-down transformer reduces the primary current.<br> True or false
    8·2 answers
  • Steam enters an adiabatic turbine at 8 MPa and 500C with a mass flow rate of 3
    11·1 answer
  • Hey any one ride dirtbikes here
    5·2 answers
  • Which of the following characteristics would not give animals an advantage in the ocean?
    13·1 answer
  • Evaluate, please show work as I don't understand. thanks
    5·1 answer
  • A. How is a decision matrix useful during the
    13·1 answer
  • What are the philological elements of interior design most like?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!