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
What is (10 to the power of three) times (3 to the power of 10)? will give brainliest
VLD [36.1K]

59,049,000 is the answer.

7 0
3 years ago
A square-thread power screw is used to raise or lower the basketball board in a gym, the weight of which is W = 100kg. See the f
KIM [24]

Answer:

power = 49.95 W

and it is self locking screw

Explanation:

given data

weight W = 100 kg = 1000 N

diameter d = 20mm

pitch p = 2mm

friction coefficient of steel f = 0.1

Gravity constant is g = 10 N/kg

solution

we know T is

T = w tan(α + φ ) \frac{dm}{2}     ...................1

here dm is = do - 0.5 P

dm = 20 - 1

dm = 19 mm

and

tan(α) = \frac{L}{\pi dm}      ...............2

here lead L = n × p

so tan(α) = \frac{2\times 2}{\pi 19}

α = 3.83°  

and

f = 0.1

so tanφ = 0.1

so that φ = 5.71°

and  now we will put all value in equation 1 we get

T = 1000 × tan(3.83 + 5.71 ) \frac{19\times 10^{-3}}{2}  

T = 1.59 Nm

so

power = \frac{2\pi N \ T }{60}     .................3

put here value

power = \frac{2\pi \times 300\times 1.59}{60}

power = 49.95 W

and

as φ > α

so it is self locking screw

 

8 0
3 years ago
To solve the problem, make assumptions for missing data and justify. Given:
finlep [7]

Answer:

5,4,1, this is a explication

6 0
2 years ago
(D)<br> 13. Describe the differences between an impact socket and a conventional socket.
docker41 [41]

Answer:

The wall of an impact socket is around 50% thicker than that of a regular socket, making it suitable for use with pneumatic impact tools, whereas regular sockets should only be used on hand tools.

Explanation:

This allows the socket to remain securely attached to the impact wrench anvil, even under high stress situations.

3 0
2 years ago
It is easy to say that an organization should hire, reward, and dismiss employees based on their character as well as their know
Nata [24]

It is possible to generate a policy in which common points such as those mentioned above are agreed in order to hire or fire employees in their function of their psychological personality, that is, the character of knowledge and skills. Depending on the company, Test could be created in order to evaluate the psychological skills of the employees, as well as Test to periodically determine how their employees are kept up to date with regard to knowledge. The cumulative filter could be done every semester, for which each employee must exceed a minimum margin of score on these tests, otherwise his position could be at risk.

At the same time, incentives can be generated for the best scores that are rewarded not only with monetary values but also with rest days, coupons in restaurants or sports, which would cause the worker to strive to be constantly learning.

This policy agreement is outside the vision and mission of the company, and whose information must be given to the worker once he begins his work activities.

5 0
3 years ago
Other questions:
  • Determine the required dimensions of a column with a square cross section to carry an axial compressive load of 6500 lb if its l
    12·2 answers
  • How does running an electric current through wire cause a magnetic field?
    6·1 answer
  • Give an example of how the fields of science, technology, and mathematics are commonly used when building a highway.
    7·1 answer
  • Compare and contrast the different forms of energy that are represented below:
    13·1 answer
  • Which type of load generates a magnetic field?
    12·1 answer
  • (1) Estimate the specific volume in cm3 /g for carbon dioxide at 310 K and (a) 8 bar (b) 75 bar by the virial equation and compa
    10·1 answer
  • The section should span between 10.9 and 13.4 cm (4.30 and 5.30 inches) as measured from the end supports and should be able to
    5·1 answer
  • ) If the blood viscosity is 2.7x10-3 Pa.s, length of the blood vessel is 1 m, radius of the blood vessel is 1 mm, calculate the
    13·1 answer
  • 1. Làm thế nào để đảm bảo tính khả thi của văn bản hành chính ?
    12·1 answer
  • 14. An engine is brought into the shop with a
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!