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
choli [55]
3 years ago
5

You are given a C program "q2.c" as below. This program is used to calculate the average word length for a sentence (a string in

a single line): Enter a sentence: It was deja vu all over again. Average word length: 3.42 For simplicity, the program considers a punctuation mark to be part of the word to which it is attached. And it displays the average word length to two decimal places.
Engineering
1 answer:
MrMuchimi3 years ago
5 0

Answer:

  1. #include <stdio.h>
  2. #include <string.h>
  3. int main()
  4. {
  5.    char sentence[100];
  6.    int i;
  7.    int wordCount = 1;
  8.    int charCount = 0;
  9.    float averageLength;
  10.    
  11.    printf("Enter a sentence: ");
  12.    gets(sentence);
  13.    
  14.    for(i = 0; i < strlen(sentence); i++){
  15.        if(sentence[i] != ' '){
  16.            charCount++;
  17.        }else{
  18.            wordCount++;
  19.        }    
  20.    }
  21.    
  22.    averageLength = (float)charCount / wordCount;
  23.    printf("Average word length: %.2f", averageLength);
  24.    
  25.    return 0;
  26. }

Explanation:

Firstly we need to import the string.h library  as we need to use strlen method to estimate the length of the input string (Line 2).

To estimate the average word length for an input sentence, we can calculate the total of characters in the sentence and then divide it by the total number of words. To do so, we first get the input sentence from the user (Line 11-12). Next, use a for loop to traverse through the sentence character by character and check if the character is not a space ' ', increment charCount by one. Whenever there is a space, this mark an end of a word and therefore increment wordCount by one (Line 18).

After the loop, we can calculate the average word length by dividing the charCount by wordCount and print the output to two decimal places (Line 22- 23).  

You might be interested in
QUESTÃO 13. Explique o uso das aspas no trecho "Darei a cada uma de vocês
lesya [120]

Answer: speaks Portuguese

Eu disse a todos a tradução para que possam te ajudar

Explanation: Y’all can help I have no idea

QUESTION 13. Explain the use of quotation marks in the excerpt "I will give each of you

seed. The one who will bring me the most beautiful flower within six months will be chosen but

wife and the future empress of China. ".

QUESTION 14. The palace servant considered the idea of ​​her daughter attending the celeb

organized by the prince of the region, a foolish idea, a madness. This is an OP

Do you agree with this opinion of the character? Justify your answer.

6 0
3 years ago
Answer ppeeeeeaaaalll
Bad White [126]

Answer:

what

Explanation:

is this an exam or an test or what is it

3 0
2 years ago
For an Otto cycle, plot the cycle efficiency as a function of compression ratio from 4 to 16.
Elza [17]

Assumptions:

  • Steady state.
  • Air as working fluid.
  • Ideal gas.
  • Reversible process.
  • Ideal Otto Cycle.

Explanation:

Otto cycle is a thermodynamic cycle widely used in automobile engines, in which an amount of gas (air) experiences changes of pressure, temperature, volume, addition of heat, and removal of heat. The cycle is composed by (following the P-V diagram):

  • Intake <em>0-1</em>: the mass of working fluid is drawn into the piston at a constant pressure.
  • Adiabatic compression <em>1-2</em>: the mass of working fluid is compressed isentropically from State 1 to State 2 through compression ratio (r).

        r =\frac{V_1}{V_2}

  • Ignition 2-3: the volume remains constant while heat is added to the mass of gas.
  • Expansion 3-4: the working fluid does work on the piston due to the high pressure within it, thus the working fluid reaches the maximum volume through the compression ratio.

         r = \frac{V_4}{V_3} = \frac{V_1}{V_2}

  • Heat Rejection 4-1: heat is removed from the working fluid as the pressure drops instantaneously.
  • Exhaust 1-0: the working fluid is vented to the atmosphere.

If the system produces enough work, the automobile and its occupants will propel. On the other hand, the efficiency of the Otto Cycle is defined as follows:

           \eta = 1-(\frac{1}{r^{\gamma - 1} } )

where:

           \gamma = \frac{C_{p} }{C_{v}} : specific heat ratio

Ideal air is the working fluid, as stated before, for which its specific heat ratio can be considered constant.

           \gamma = 1.4

Answer:

See image attached.

5 0
3 years ago
Consider fully developed laminar flow in a circular pipe. If the viscosity of the fluid is reduced by half by heating while the
gladu [14]

Answer:

The pressure drop across the pipe also reduces by half of its initial value if the viscosity of the fluid reduces by half of its original value.

Explanation:

For a fully developed laminar flow in a circular pipe, the flowrate (volumetric) is given by the Hagen-Poiseulle's equation.

Q = π(ΔPR⁴/8μL)

where Q = volumetric flowrate

ΔP = Pressure drop across the pipe

μ = fluid viscosity

L = pipe length

If all the other parameters are kept constant, the pressure drop across the circular pipe is directly proportional to the viscosity of the fluid flowing in the pipe

ΔP = μ(8QL/πR⁴)

ΔP = Kμ

K = (8QL/πR⁴) = constant (for this question)

ΔP = Kμ

K = (ΔP/μ)

So, if the viscosity is halved, the new viscosity (μ₁) will be half of the original viscosity (μ).

μ₁ = (μ/2)

The new pressure drop (ΔP₁) is then

ΔP₁ = Kμ₁ = K(μ/2)

Recall,

K = (ΔP/μ)

ΔP₁ = K(μ/2) = (ΔP/μ) × (μ/2) = (ΔP/2)

Hence, the pressure drop across the pipe also reduces by half of its initial value if the viscosity of the fluid reduces by half of its value.

Hope this Helps!!!

4 0
3 years ago
At a certain location, wind is blowing steadily at 5 mph. Suppose that the mass density of air is 0.0796 lbm/ft3 and determine t
nlexa [21]

Answer:

The radius of a wind turbine is 691.1 ft

The power generation potential (PGP) scales with speed at the rate of 7.73 kW.s/m

Explanation:

Given;

power generation potential (PGP) = 1000 kW

Wind speed = 5 mph = 2.2352 m/s

Density of air = 0.0796 lbm/ft³ = 1.275 kg/m³

Radius of the wind turbine r = ?

Wind energy per unit mass of air, e = E/m = 0.5 v² = (0.5)(2.2352)²

Wind energy per unit mass of air = 2.517 J/kg

PGP = mass flow rate * energy per unit mass

PGP = ρ*A*V*e

PGP = \rho *\frac{\pi r^2}{2} *V*e  \\\\r^2 = \frac{2*PGP}{\rho*\pi *V*e} , r=\sqrt{ \frac{2*PGP}{\rho*\pi *V*e}} = \sqrt{ \frac{2*10^6}{1.275*\pi *2.235*2.517}}

r = 210.64 m = 691.1 ft

Thus, the radius of a wind turbine is 691.1 ft

PGP = CVᵃ

For best design of wind turbine Betz limit (c) is taken between (0.35 - 0.45)

Let C = 0.4

PGP = Cvᵃ

take log of both sides

ln(PGP) = a*ln(CV)

a = ln(PGP)/ln(CV)

a = ln(1000)/ln(0.4 *2.2352) = 7.73

The power generation potential (PGP) scales with speed at the rate of 7.73 kW.s/m

5 0
3 years ago
Other questions:
  • True or False: Drag and tailwind are examples of a contact force.<br> tyy guyss
    14·1 answer
  • In order to build a skyscraper Builders, Inc. hires 400 construction workers and 50 managers. Builders, Inc. represents A entrep
    8·1 answer
  • In order to protect yourself if you have a dispute with another drivers insurance company you should:
    9·1 answer
  • When choosing a respirator for your job, you must conduct a _____ test.
    15·1 answer
  • A 200-gr (7000 gr = 1 lb) bullet goes from rest to 3300 ft/s in 0.0011 s. Determine the magnitude of the impulse imparted to the
    10·1 answer
  • Has anyone lost faith in humanity ✌️
    7·1 answer
  • Help me, iv been having problems with ads going in my phones storage files, what can i do to stop this?
    14·2 answers
  • For two different air velocities, the Nusselt number for two different diameter cylinders in cross flow is the same. The average
    6·1 answer
  • Evaluate, please show work as I don't understand. thanks
    5·1 answer
  • When a company in the United States employs people in India to answer their customer service calls this is an example of
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!