Enter a series of floating point numbers

Assignment Help Business Management
Reference no: EM132260949

question:

Write a program (in C language) that prompts the user to enter a series of floating point numbers and calculate the average. You don't know how many numbers the user will input. The program will stop when the user enters a negative number. Display the following message at the end:

a) n numbers were entered

b) The average is avg

I attempted answering this question but my code isn't working,i have written my working please give me a correct solution to this.

here's my working:

#include <stdio.h>

main(void){

int i=1,n;

double avg,sum=0;

while (i>0){

printf("enter a value for in");

scanf("%lf",&i);

if (i<0){

break;

}

else{

sum=sum+i;

n=i;

i++;

}

}

printf("%d numbers were printedn",n);

avg=sum/n;

printf("the average is %.4lfn",avg);

return(0);

}

Reference no: EM132260949

Questions Cloud

Discuss security design principles utilizing : Discuss security design principles utilizing different authentication methods and (password) policies
What are if-then and loop using variables : What are if-then, and loop using variables? What is an example of them?
Explains the benefits and limitations of the star : Explains the benefits and limitations of the Star, Bus, Ring and Mesh network topologies. Explains the various network devices that will be seen in those
What are thoughts on the role : What are your thoughts on the role that you can personally play in promoting greener computing habits?
Enter a series of floating point numbers : You don't know how many numbers the user will input. The program will stop when the user enters a negative number.
Html scripting experience training : Which methods require coding/ html scripting experience training? Are any methods appropriate for non-technical purposes?
Based on the given probability distribution : Based on the given probability distribution and the order size, for the given random number Barbara’s SALES and PROFIT are?
Bank bound by unsigned lehman deal despite dismissal : In the article, Bank Bound By Unsigned Lehman Deal Despite Dismissal, it states, “Shinhan and Lehman reached agreement with the help of a mediator in April 2016
Would e-mail be sufficient to substantiate agreement : Would an e-mail be sufficient to substantiate an agreement, enough that it would not require a signature for a deal to be made? Why or why not?

Reviews

Write a Review

Business Management Questions & Answers

  Associate general counsel of the sec

The following quote is taken from Phillip D. Parker (Associate General Counsel of the SEC), "Market Value Accounting-An Idea Whose Time Has Come?

  Read what are business metrics

Read What Are Business Metrics? and Measuring Communication Effectiveness Across Diverse Backgrounds and Missions. In your initial post

  What type of business market customers does camelbak sell to

Discuss how business relationships and strategic partnerships have helped to increase the value of CamelBak's products and the business itself.

  Present to a group of executives

You have to develop a staffing model for your ideal fitness center to present to a group of executives.

  Explaining contemporary social problem

Summarize your views on how a specific contemporary social problem is having an impact on your workplace or on workplaces known to you.

  Compare the three sales force structures

Compare the three sales force structures outlines in the Kotler textbook. Which is the most effective. Why?

  Dead weight lossarising from the monopoly equilibrium

Verify the monopolist equilibrium is (Q=20,P=60). What isthe perfectly competitive equilibrium? Calculate dead weight lossarising from the monopoly equilibrium.

  Rank the given factors in order of importance

Discussion Pitch Perfect- Then rank the following factors in order of importance when developing an elevator speech, and provide a rationale for your response.

  Why is there a social cost to monopoly power

Why is there a social cost to monopoly power? If the gains to producers from monopoly power could be redistributed to consumers, would the social cost of monopoly power be eliminated? Explain briefly.

  Economy and development of communities and society

Anyone could help me with a conclusion or summary for positive that immigrants have on economy and development of communities and society.

  Scope of practice for healthcareyou have just gotten a job

scope of practice for healthcareyou have just gotten a job at a hospital working in the reception area of the emergency

  Which of the subsequent is true regarding her situation

She tells you who she has been advised which she is going to be charged with a securities violation involving insider trading. Which of the subsequent is true regarding her situation?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd