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
o-na [289]
3 years ago
12

A) Fix any errors to get the following program to run in your environment. B) Document each line of code with comments and descr

ibe any changes you had to make to the original code to get it to work. C) Write a summary of what your final version of the program does.
You may also add white space or reorder the code to suit your own style as long as the intended function does not change.

#include
using namespace std;

void m(int, int []);
void p(const int list[], int arraySize)
{
list[0] = 100;
}

int main()
{
int x = 1;
int y[10];
y[0] = 1;

m(x, y);

cout << "x is " << x << endl;
cout << "y[0] is " << y[0] << endl;

return 0;
}

void m(int number, int numbers[])
{
number = 1001;
numbers[0] = 5555;
}
Engineering
1 answer:
Bingel [31]3 years ago
4 0

Answer:

Answer is explained below

Explanation:

<u>Part A -: </u>

<u> </u>

<u>Error statement -: </u>

/*

prog.cpp: In function ‘void p(const int*, int)’:

prog.cpp:7:15: error: assignment of read-only location ‘* list’

list[0] = 100;

*/

There is one error in the code in following part

void p( const int list[], int arraySize)

{

list[0] = 100;

}

you are passing list as constant but changing it inside the function that is not allowed. if you pass any argument as const then you can't change it inside the function. so remove const from function argument solve the error.

<u>Part B -: </u>

change made

void p( int list[], int arraySize)

{

list[0] = 100;

}

<u>Executable fully commented code -: </u>

#include <iostream> // importing the iostream library

using namespace std;

void m(int, int []); // Function declearation of m

void p( int list[], int arraySize) // definition of Function p

{

list[0] = 100; // making value of first element of list as 100

}

int main()

{

int x = 1; // initilizing x with 1

int y[10]; // y is a array of 10 elements

y[0] = 1; // first element of y array is 1

m(x, y); // call m function

// printing the desired result

cout << "x is " << x << endl;

cout << "y[0] is " << y[0] << endl;

return 0;

}

void m(int number, int numbers[]) // Function definition of m

{

number = 1001; // value of number is 1001 locally

numbers[0] = 5555; // making value of first element of numbers array 5555

}

Part C :-

In program we initilize x with value 1 and create an array y of 10 elements.

we initilize the y[0] with 1\

then we call function m. In function m ,first argument is value of x and second argument is the pointer to the first element of array y.

so value of x is changed locally in function m and change is not reflected in main function.

but value of y[0] is changed to 5555 because of pass by refrence.

So we are getting the following result :-

x is 1

y[0] is 5555

You might be interested in
The diffusion coefficients for species A in metal B are given at two temperatures:
Kruka [31]

Answer:

a) 149 kJ/mol, b) 6.11*10^-11 m^2/s ,c) 2.76*10^-16 m^2/s

Explanation:

Diffusion is governed by Arrhenius equation

D = D_0e^{\frac{-Q_d}{RT} }

I will be using R in the equation instead of k_b as the problem asks for molar activation energy

I will be using

R = 8.314\ J/mol*K

and

°C + 273 = K

here, adjust your precision as neccessary

Since we got 2 difusion coefficients at 2 temperatures alredy, we can simply turn these into 2 linear equations to solve for a) and b) simply by taking logarithm

So:

ln(6.69*10^{-17})=ln(D_0) -\frac{Q_d}{R*(1030+273)}

and

ln(6.56*10^{-16}) = ln(D_0) -\frac{Q_d}{R*(1290+273)}

You might notice that these equations have the form of  

d=y-ax

You can solve this equation system easily using calculator, and you will eventually get

D_0 =6.11*10^{-11}\ m^2/s\\ Q_d=1.49 *10^3\ J/mol

After you got those 2 parameters, the rest is easy, you can just plug them all   including the given temperature of 1180°C into the Arrhenius equation

6.11*10^{-11}e^{\frac{149\ 000}{8.143*(1180+273)}

And you should get D = 2.76*10^-16 m^/s as an answer for c)

5 0
3 years ago
A 2-cm-diameter vertical water jet is injected upward by a nozzle at a speed of 15 m/s. Determine the maximum weight of a flat p
Ede4ka [16]

Answer:58.28 N

Explanation:

Given data

dia. of nozzle \left ( d\right )=2 cm

initial velocity\left ( u\right )=15 m/s

height\left ( h\right )=2m

Now velocity of jet at height of 2m

v^2-u^2=2gh

v^2=15^2-2\left ( 9.81\right )\left ( 2\right )

v=\sqrt{185.76}=13.62 m/s

Now\ forces\ on\ plate\ are\ weight\left ( Downward\right ) and jet\ force\left ( upward\right )

equating them

W=\left ( \rho Av\right )v

W=10^{3}\times \frac{\pi}{4}\left ( 0.02\right )^2\times 13.62^2

W=58.28 N

7 0
4 years ago
A water supply agency is planning to add two reservoirs to its system. Water will flow from Reservoir A to Reservoir B via a 10,
NikAS [45]

Attached is the solution to the above question.

3 0
4 years ago
Comparación de hipotecas Los Chos
aleksklad [387]

Answer:

I don't understand the language French sorry can't answer

3 0
3 years ago
A large fraction of the thermal energy generated in the engine of a car is rejected to the air by the radiator through the circu
Rina8888 [55]
Open system because there is mass (water) flowing through the system of interest (radiator)
5 0
3 years ago
Other questions:
  • Liquid flows at steady state at a rate of 2 lb/s through a pump, which operates to raise the elevation of the liquid 100 ft from
    6·1 answer
  • Which of the following is not an example of heat generation? a)- Exothermic chemical reaction in a solid b)- Endothermic Chemica
    15·1 answer
  • Determine the total condensation rate of water vapor onto the front surface of a vertical plate that is 10 mm high and 1 m in th
    8·2 answers
  • Burn in hell i watched your stupid video and i still could not get the answer
    14·1 answer
  • name the process by which mild steel can be converted into high carbon steel and explain it briefly ?​
    12·1 answer
  • A private plane pilot is what kind of individual transportation position? professional level mid-level entry-level EPA-certified
    9·1 answer
  • 1. A hydro facility operates with an elevation difference of 50 m and a flow rate of 500 m3/s. If the rotational speed is 90 RPM
    12·1 answer
  • Find the remaining trigonometric function of 0 if
    13·1 answer
  • Workplace bullying can cause_____hazards.
    7·1 answer
  • What type of social engineering targets particular?.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!