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
Leviafan [203]
3 years ago
13

13. Write a function which is passed two strings. The function creates a new string from the two original strings by copying one

character from each in turn until all characters have been copied.

Engineering
1 answer:
attashe74 [19]3 years ago
3 0

Answer:

I am writing the code in C++. Let me know if you want the program in some other programming language.

#include <iostream>  // includes header file for input output functions

using namespace std;     //to identify objects like cin cout

string CopyStrings(string string1, string string2)  

{   string newString = "";    

   for (int loop = 0; loop < string1.length() ||  

                   loop < string2.length(); loop++)      {      

       if (loop < string1.length())  

           newString += string1[loop];          

       if (loop < string2.length())  

           newString += string2[loop];      }  

   return newString;   }  

int main()  

{   string stringA = "ace";  

   string stringB = "bdf";  

   cout << CopyStrings(stringA, stringB);   }

Output:

abcdef

Explanation:

The function CopyStrings() function takes two strings i.e. string1 and string2 as parameters to copy characters from both the string one character from each.

The newString variable stores the new string after copying characters from both strings string1 and string2.

Then the for loop starts which has a variable loop which is an index variable that traverses through both the strings stored in string1 and string2. The loop continues to execute until it moves through entire length of string1 and string2 which means it copies all the characters from both string1 and string2. length() is used here which returns length of the string1 and string2.

If statement in the for loop checks the character that loop (index) variable is pointing to is less than the string1 length which means it checks each character stored in string1. For example if string1 contains "ace" and loop variable is moving through the string and is currently at "a" then this condition is true. If the condition evaluates to true then the body of if statement is executed. The next statement stores that character a into the newString variable.

Next If statement checks character that loop variable is pointing to is less than the string2 length which means it checks each character stored in string2. For example if string2 contains "bdf" and loop variable is moving through the string and is currently at "b" then this condition is true. If the condition evaluates to true then the body of if statement is executed. The next statement stores that character b into the newString variable.

Then the second iteration starts which again first stores the next character i.e. c from string1 into newString and then stores next character i.e d from string2 into newString.

Then the third iteration starts which again first stores the next character i.e. e from string1 into newString and then stores next character i.e f from string2 into newString.

Then the loop breaks as the loop variable reaches end of both the string1 and string2.

return newString will return the copied string into the output screen which is abcdef.

The screenshot of code along with output is attached.

You might be interested in
Technician A says if the input signal turn-on time is too fast for the input circuit, your program may operate as though the inp
ASHA 777 [7]

Answer:

b. Technician B only

Explanation:

A watchdog timer is a circuit that automatically monitors the MCU (Microcontroller Unit) for any anomaly, detects it and helps the MCU to recover from the malfunction it has detected.

If the input signal turn-on time is too fast for the input circuit, that is a malfunction and this activates the watchdog timer circuit to correct this malfunction immediately. So Technician B only is correct as the watchdog timer is activated immediately once there is a malfunction.

7 0
2 years ago
simple Brayton cycle using air as the working fluid has a pressure ratio of 10. The minimum and maximum temperatures in the cycl
Irina18 [472]

Answer:

a) 764.45K

b) 210.48 kJ/kg

c) 30.14%

Explanation:

pressure ratio = 10

minimum temperature = 295 k

maximum temperature = 1240 k

isentropic efficiency for compressor = 83%

Isentropic efficiency for turbine = 87%

<u>a) Air temperature at turbine exit </u>

we can achieve this by interpolating for enthalpy

h4 = 783.05 kJ/kg ( calculated in the background ) at state 4 using Table A-17  for  Ideal gas properties of air

T4 ( temperature at Turbine exit ) = 760 + ( 780 - 760 ) (\frac{783.05-778.18}{800.13-778.18} ) = 764.45K

<u>b) The net work output </u>

first we determine the actual work input to compressor

Wc = h2 - h1  ( calculated values )

     = 626.57 - 295.17 =  331.4 kJ/kg

next determine the actual work done by Turbine

Wt = h3 - h4  ( calculated values )

     = 1324.93 - 783.05 = 541.88 kJ/kg

finally determine the network output of the cycle

Wnet = Wt - Wc

         = 541.88 - 331.4  = 210.48 kJ/kg

<u>c) determine thermal efficiency </u>

лth = Wnet / qin  ------ ( 1 )

where ; qin = h3 - h2

<em>equation 1 becomes </em>

лth = Wnet / ( h3 - h2 )

      = 210.48 / ( 1324.93 - 626.57 )

      = 0.3014  =  30.14%

6 0
3 years ago
Which metal is used in planes.
wel

Answer:

<h2>Steel</h2>

Explanation:

Steel is the metal that using in planes.

Aluminum and titanium also used in this aircraft industry.

Aluminum is ideal for aircraft manufacture because it's lightweight and strong.

<em>hope</em><em> </em><em>this</em><em> </em><em>helps</em><em>!</em><em>!</em>

<em>have</em><em> </em><em>a</em><em> </em><em>nice</em><em> </em><em>day</em><em>!</em>

<em>follow</em><em> </em><em>me</em><em> </em><em>=</em><em>=</em><em>></em><em> </em><em>Hi1315</em>

5 0
2 years ago
Read 2 more answers
A gas turbine receives a mixture having the following molar analysis: 10% CO2, 19% H2O, 71% N2 at 720 K, 0.35 MPa and a volumetr
Sliva [168]

Answer:

2074.2 KW

Explanation:

<u>Determine power developed at steady state </u>

First step : Determine mass flow rate  ( m )

m / Mmax = ( AV )₁ P₁ / RT₁   -------------------- ( 1 )

<em> where : ( AV )₁ = 8.2 kg/s,  P₁ = 0.35 * 10^6 N/m^2,   R = 8.314 N.M / kmol , </em>

<em>  T₁  = 720 K . </em>

insert values into equation 1

m  = 0.1871  kmol/s  ( mix )

Next : calculate power developed at steady state ( using ideal gas tables to get the h values of the gases )

W( power developed at steady state )

W = m [ Yco2 ( h1 - h2 )co2

Attached below is the remaining  part of the detailed solution

4 0
3 years ago
A four-cylinder, four-stroke internal combustion engine has a bore of 3.7 in. and a stroke of 3.4 in. The clearance volume is 16
abruzzese [7]

Answer:

1) The three possible assumptions are

a) All processes are reversible internally

b) Air, which is the working fluid circulates continuously in a closed loop

cycle

c) The process of combustion is depicted as a heat addition process

2) The diagrams are attached

5) The net work per cycle is 845.88 kJ/kg

The power developed in horsepower ≈ 45374 hP

Explanation:

1) The three possible assumptions are

a) All processes are reversible internally

b) Air, which is the working fluid circulates continuously in a closed loop

cycle

c) The process of combustion is depicted as a heat addition process

2) The diagrams are attached

5) The dimension of the cylinder bore diameter = 3.7 in. = 0.09398 m

Stroke length = 3.4 in. = 0.08636 m.

The volume of the cylinder v₁= 0.08636 ×(0.09398²)/4 = 5.99×10⁻⁴ m³

The clearance volume = 16% of cylinder volume = 0.16×5.99×10⁻⁴ m³

The clearance volume, v₂  = 9.59 × 10⁻⁵ m³

p₁ = 14.5 lbf/in.² = 99973.981 Pa

T₁ = 60 F = 288.706 K

\dfrac{T_{2}}{T_{1}} = \left (\dfrac{v_{1}}{v_{2}}  \right )^{K-1}

Otto cycle T-S diagram

T₂ = 288.706*6.25^{0.393} = 592.984 K

The maximum temperature = T₃ = 5200 R = 2888.89 K

\dfrac{T_{3}}{T_{4}} = \left (\dfrac{v_{4}}{v_{3}}  \right )^{K-1}

T₄ = 2888.89 / 6.25^{0.393} = 1406.5 K

Work done, W = c_v×(T₃ - T₂) - c_v×(T₄ - T₁)

0.718×(2888.89  - 592.984) - 0.718×(1406.5 - 288.706) = 845.88 kJ/kg

The power developed in an Otto cycle = W×Cycle per second

= 845.88 × 2400 / 60  = 33,835.377 kW = 45373.99 ≈ 45374 hP.

8 0
3 years ago
Other questions:
  • What is the damped natural frequency (in rad/s) of a second order system whose undamped natural frequency is 25 rad/s and has a
    15·1 answer
  • Suppose that a wing component on an aircraft is fabricated from an aluminum alloy that has a plane strain fracture toughness of
    13·1 answer
  • Yasir is trying to build an energy-efficient wall and deciding what materials to use. How can he calculate the thermal resistanc
    6·1 answer
  • Given a series of numbers as input, add them up until the input is 10 and print the total. Do not add the final 10. For example,
    7·1 answer
  • Technician A says that latent heat is hidden heat and cannot be measured on a thermometer. Technician B says that latent heat is
    12·1 answer
  • Anne-Marie Cole runs the sales division for a local auto insurance firm. One of her key duties is to calculate her company's mar
    11·2 answers
  • 1)A wheel is used to turn a valve stem on a water valve. If the wheel radius is 1 foot and the stem, (axle), radius is .5 inches
    10·1 answer
  • The cars of a roller-coaster ride have a speed of 30 km / h as they pass over the top of the circular track. Neglect any frictio
    9·1 answer
  • Which of the following characteristics would not give animals an advantage in the ocean?
    13·1 answer
  • 11. As __and___ prices continued to rise in the late 1960’s and 70's, 4 and 6 cylinder engines began to make a comeback.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!