The following program supposes to sum all entered int values that are greater than 5. It...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
The following program supposes to sum all entered int values that are greater than 5. It takes integer input and -1 indicates the end of input. It compiles without any error message, and it executes without error message, but nevertheless is wrong. What is wrong with the program? #include <stdio.h> int main() { } int x, sum = 0; while (x!= -1) { } scanf("%d",&x); if (x > 5); sum sum +x; printf("The sum of values > 5 is %d\n", sum); The semicolon at the end of the if statement causes all entered values to be summed. The semicolon at the end of the if statement is an error that the compiler should catch. The while loop does not terminate when input is -1. The while header needs a semicolon at the end of its line. Activate Windows Go to Settings to activate Wi The following program supposes to sum all entered int values that are greater than 5. It takes integer input and -1 indicates the end of input. It compiles without any error message, and it executes without error message, but nevertheless is wrong. What is wrong with the program? #include <stdio.h> int main() { } int x, sum = 0; while (x!= -1) { } scanf("%d",&x); if (x > 5); sum sum +x; printf("The sum of values > 5 is %d\n", sum); The semicolon at the end of the if statement causes all entered values to be summed. The semicolon at the end of the if statement is an error that the compiler should catch. The while loop does not terminate when input is -1. The while header needs a semicolon at the end of its line. Activate Windows Go to Settings to activate Wi
Expert Answer:
Answer rating: 100% (QA)
The issue with the program is the misplaced closing brace for the while lo... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
A heat engine cycle is executed with ammonia in the saturation dome. The pressure of ammonia is 1.5 MPa during heat addition and 0.6 MPa during heat rejection. What is the highest possible thermal...
-
Rojas Vineyards in Oakville, California, produces three varieties of non-alcoholic wine: merlot, viognier, and pinot noir. The wine-master, Russel Hansen, has identified the following activities as...
-
Oxford Company has limited funds available for investment and must ration the funds among four competing projects. Selected information on the four projects follows: Project Investment Required...
-
The following MINITAB output presents the results of a hypothesis test for a mean difference. a. Is this a left-tailed test, a right-tailed test, or a two-tailed test? b. Can H0 be rejected at the...
-
1. G. Johnson and colleagues have analyzed the MAP kinase cascade in which MEKK2 participates in mammalian cells. By a yeast two-hybrid screen (see Chapter 7), MEKK2 was found to bind MEK5, which can...
-
Jos Ruiz starts a company that makes handcrafted birdhouses Competitors sell a similar birdhouse for $240 each. Jose believes he can produce a birdhouse for a total cost of $205 per unit, and he...
-
Show that if G is a CFG in Chomsky normal form, then for any string w L(G) of length n 1, exactly 2n 1 steps are required for any derivation of w.
-
A businessman wishes to borrow an amount of K1 million for a term of 5 years. The agreed rate of interest is 8% per annum effective for the first 3 years, and 6% per annum effective thereafter....
-
1. What does a formal letter offer that electronic communication does not? 2. Three instances where a formal letter would be more appropriate than electronic communication. 3. Situations where people...
-
Del Gato Clinic's cash account shows an $12,937 debit balance and its bank statement shows $11,548 on deposit at the close of business on June 30. a. Outstanding checks as of June 30 total $1,469. b....
-
Debra Leasing Company signs an agreement on January 1, 2025, to lease equipment to Marin Company. The following information relates to this agreement. 1. 2. 3. The term of the non-cancelable lease is...
-
1. Does alcohol fermentation occur in humans? If not, what formsof fermentation do occur in humans, if any? 2. Which type of cells in the body do you think require the mostenergy during vigorous...
-
Discuss the concerns that still need to be addressed regarding police use of body cameras? What are some of the problems involving police use of force and the various studies that have been done?
-
The First National Bank is the most popular bank in town, but it is unable to loan additional money to any of its customers. Which of the following might explain this? O There are lending limits in...
-
State whether each statement is true or false. If false, give a reason. {purple, green, yellow} = {green, pink, yellow}
-
Describe the key features of cloud computing.
-
Why is it important to denormalize data in a data warehouse?
-
Mary Johnson, the Ajax Construction Co. cash disbursement clerk, has the database access privileges presented in the table below. Required: Discuss the appropriateness of the access privileges...
-
The beam is made from a plate that has a constant thickness \(t\). Determine the width \(w\) as a function of \(x\) so that it has a maximum bending stress \(\sigma_{\max }\) throughout its length...
-
The beam has a constant thickness \(b\). If it supports the distributed loading shown, determine the maximum bending stress \(\sigma_{\max }\) in the beam. ho 22 -- Wo 2ho I ho 22
-
The beam is made from a plate having a constant thickness \(t\) and a width that varies as shown. If it supports a concentrated force \(\mathbf{P}\) at its center, determine the absolute maximum...
Study smarter with the SolutionInn App