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
Sam’s father bought him a new car for $26,304.00. He expects to pay for it in equal monthly payments for 60 months. How much wil
Alex_Xolod [135]

Answer:

438.4$ each month

Explanation:

you get this answer by dividing the total payment by the months

8 0
3 years ago
Read 2 more answers
Under normal conditions, gauge pressure is ______ absolute pressure.
levacccp [35]

Answer:

Option B  Lower than

Explanation:

Gauge pressure is a relative measurement based on atmospheric pressure. Gauge pressure can be positive if it is above atmospheric pressure or it can also be negative it is below.  On another hand, absolute pressure is an actual pressure in a space and its value has always to be zero or above. Basically absolute pressure is zero if it is in a perfect vacuum. So the measurement of absolute pressure is gauge pressure + atmospheric pressure.  This is the reason in normal condition the gauge pressure = absolute pressure - atmospheric pressure and therefore is lower than absolute pressure

3 0
4 years ago
Which of the following describes how the author introduces dust storms in the text??​
Oduvanchick [21]

Answer:

B-as deadly storms that claim lives in th great pines

Explanation:

I hope it helped if it did pls make me brainliest

8 0
3 years ago
Read 2 more answers
Compare and contrast an electric vehicle with one powered by a fuel cell.
zmey [24]

Answer:

both technologies offer a cleaner alternative to internal combustion engines, and both use electric motors powered by electrochemical device.

3 0
3 years ago
A soil is at a void ratio e = 0.90 with a specific gravity of the solid particles Gs = 2.70.
Alexus [3.1K]

Answer:

The correct answers are:

a. % w = 33.3%

b. mass of water = 45g

Explanation:

First, let us define the parameters in the question:

void ratio e  = \frac{V_v}{V_s} =  \frac{\left\begin{array}{ccc}volume&of&void\end{array}\right}{\left\begin{array}{ccc}volume&of&solid\end{array}\right}------ (1)

Specific gravity G_{s} = \frac{P_s}{P_w} =  \frac{\left\begin{array}{ccc}density&of&soil\end{array}\right}{\left\begin{array}{ccc}density&of&water\end{array}\right}------ (2)

% Saturation S = \frac{V_w}{Vv} × \frac{100}{1} =  \frac{\left\begin{array}{ccc}volume&of&water\end{array}\right}{\left\begin{array}{ccc}volume&of&void\end{array}\right} × \frac{100}{1}--------(3)

water content w =  \frac{M_w}{M_s} = \frac{\left\begin{array}{ccc}mass&of&water\end{array}\right}{\left\begin{array}{ccc}mass&of&solid\end{array}\right} ------(4)

a) To calculate the lower and upper limits of water content:

when S = 100%, it means that the soil is fully saturated and this will give the upper limit of water content.

when S < 100%, the soil is partially saturated, and this will give the lower limit of water content.

Note; S = 0% means that the soil is perfectly dry. Hence, when s = 1 will give the lowest limit of water content.

To get the relationship between water content and saturation, we will manipulate the equations above;

w =  \frac{M_w}{Ms}

Recall; mass = Density × volume

w = \frac{V_wP_w}{V_sP_s} ------(5)

From eqn. (2)  G_{s} = \frac{P_s}{P_w}

∴ \frac{1}{G_s} = \frac{P_w}{P_s} ------(6)

putting eqn. (6) into (5)

w = \frac{V_w}{V_sG_s} -----(7)

Again, from eqn (1)

V_s = \frac{V_v}{e}

substituting into eqn. (7)

w = \frac{V_w}{\frac{V_v}{e}{G_s} } = \frac{V_w e}{V_vG_s} \\ but \frac{V_w}{V_v}  = S

∴ w = \frac{Se}{G_s} -----(8)

With eqn. (7), we can calculate

upper limit of water content

when S = 100% = 1

Given, G_{s} = 2.7, e= 0.9

∴w= \frac{0.9*1}{2.7} = 0.333

∴ %w = 33.3%

Lower limit of water content

when S = 1% = 0.01

w= \frac{0.01*0.9 }{2.7} = 0.0033

∴ % w = 0.33%

b) Calculating mass of water in 100 cm³ sample of soil (P_w=\frac{1_g}{cm^{3} } )

Given, V_{s} = 100 cm^{3 }, S = 50% = 0.5

%S = \frac{V_w}{V_v} × \frac{100}{1} = \frac{V_w}{eV_s} × \frac{100}{1}

0.50 = \frac{V_w}{0.9* 100}  = 45cm^{3}

mass of water = P_wV_w= 1 * 45 = 45_{g}

7 0
4 years ago
Other questions:
  • Which of the following sentences correctly uses commas after prepositional phrases
    14·1 answer
  • 1. Add:<br>(i) 5xy, -2xy, -11xy, 8xy<br>(iv) 3a - 2b + c, 5a + 8b -70​
    8·1 answer
  • Click this link to view O*NET’s Work Context section for Loading Machine Operators. Note that common contexts are listed toward
    10·1 answer
  • You are the project manager assigned to construct a new 10-story office building. You are trying to estimate the costs for this
    10·1 answer
  • Which federal agency issues the model food code?
    7·2 answers
  • An electrical current of 700 A flows through a stainlesssteel cable having a diameter of 5 mm and an electricalresistance of 610
    15·1 answer
  • When designing a new product, which type of drawing is usually made FIRST?
    11·1 answer
  • A 35 ft long solid steel rod is subjected to a load of 8,000 lb. This load causes the rod to stretch 0.266 in. The modulus of el
    9·1 answer
  • Name the manufacturing process that the worker is using to create the workpiece. The manufacturing process carried out by the bl
    6·1 answer
  • How far away must a pwc stay from anyone being towed behind another vessel?.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!