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
Bad White [126]
3 years ago
14

Write a fragment of code that reads in integers from standard input, until end-of-file and sends their (floating point) average

to standard output. If no numbers are input, the message "no values to average" is printed instead (while loops, end-of-file processing, mixed-mode arithmetic, basic conditional)
Computers and Technology
1 answer:
nydimaria [60]3 years ago
6 0

Answer:

float number=-1;

float count=0;

float sum=0;

while(cin.eof()==false){

cin >> number;

sum += number;

count++;

}

if(number==-1){

cout << "no values to average";

}

else{

if (count>0)

cout << sum/count;

}

You might be interested in
Write a function shampoo_instructions() with parameter num_cycles. If num_cycles is less than 1, print "Too few.". If more than
EastWind [94]

Answer:

Following are the code to the given question:

def shampoo_instructions(num_cycles):#defining a method shampoo_instructions that accepts num_cycles as a parameter

   if num_cycles < 1:#defining an if block that num_cycles value is less than 1

       print('Too few.')#print message  

   elif num_cycles > 4:#defining elif block that checks num_cycles is greater than 4

       print('Too many.')#print message  

   else:#defining else block

       N= 1;#defining N variable that holds a value 1

       for N in range(N, num_cycles+1):#defining for loop that check value in range

           print(N , ": Lather and rinse.")#print message  

       print('Done.')#print message  

shampoo_instructions(2)#calling the method

Output:

1 : Lather and rinse.

2 : Lather and rinse.

Done.

Explanation:

In this code, a method "shampoo_instructions" is defined, that accepts a variable "num_cycles" in its parameter, and in the next step, the multiple conditional statements have used that check the "num_cycles" values which can be defined as follows:

  • The if the block checks the parameter value is less than 1, and it prints the value as the message.
  • In the next step, the elif block is used that checks parameter value is greater than 4, and it prints the value as the message.
  • In the else block, it uses the for loop that checks the value in the range and prints its value and calling the method.
6 0
3 years ago
Does anyone know about the progressive era?
Umnica [9.8K]

Answer: The Progressive Era was a period of widespread social activism and political reform across the United States that spanned the 1890s to the 1920s.

Explanation:

8 0
4 years ago
Read 2 more answers
Which finger is the correct finger to key the letter "O"?
Lorico [155]

Answer:

probably the pincky finger I don't know I use what ever

3 0
3 years ago
After configuring the role services on the Remote Desktop server, Jabez creates a collection for the Marketing group in the orga
lawyer [7]

The option that  is true is option C: Jabez created a shared folder that is accessible to remote servers in the collection.

<h3>What are servers?</h3>

A server is known to be a form a computer program or device that helps to give a service to a given computer program and its user.

Note that in the case above, The option that  is true is option C: Jabez created a shared folder that is accessible to remote servers in the collection.

Learn more about servers from

brainly.com/question/17062016

#SPJ1

8 0
2 years ago
What is the meaning of the term plot?<br>A. the final outcome of the story​
Amanda [17]

Answer:

The meaning of the term plot is the plan, scheme, or main story of a literary or dramatic work, as a play, novel, or short story.

Explanation:

5 0
3 years ago
Other questions:
  • Why are there 2 types of ip addresses like 172.16.254.1 or 2001:db8:0:1234:0:567:8:1?
    10·1 answer
  • A good example of an agency relationship in a hotel is the relationship between a bartender and a server. True False
    6·1 answer
  • Xbrl taxonomy: is the document format used to produce web pages. is the final product (report. is a classification scheme. is a
    12·1 answer
  • Michael is trying to remember his friend’s new cell phone number. He repeats it in his mind until he gets the new number entered
    8·2 answers
  • Information technology has powerful effects on social behavior. Which of the following issues should NOT be expected when intera
    11·1 answer
  • What is the role of consumers in determining what is produced in a market economy
    15·2 answers
  • Role and importance of internet in today's world
    9·2 answers
  • How to hide location on iphone without them knowing?.
    5·1 answer
  • list three things that can spoil a printer if they are not of the correct specification and what damage may be caused​
    9·1 answer
  • Intro Programming - Problem(s)
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!