Write a C program segment that computes 1 + 2 + 3+...+(n-1) + n, where n...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a C program segment that computes 1 + 2 + 3+...+(n-1) + n, where n is a positive integer value greater than 1. Assume that you enter an integer, but make sure that you validate that it is a positive integer that is greater than 1. Follow the loop body with an if statement that compares n(n+1) this value to and displays a message that indicates whether the values are the same or different. What message do you think will be displayed? 2 • Following are two sample runs: ■ Sample Run 1: Enter an integer value greater than 1 : 5 sum of numbers from 1 to 5 = 15 ■ Sample Run 2: Enter an integer value greater than 1 : 0 Wrong input try again Enter an integer value greater than 1 : -5 Wrong input try again Enter an integer value greater than 1 : 1 Wrong input try again Enter an integer value greater than 1 20 sum of numbers from 1 to 20 = 210 Write a C program segment that computes 1 + 2 + 3+...+(n-1) + n, where n is a positive integer value greater than 1. Assume that you enter an integer, but make sure that you validate that it is a positive integer that is greater than 1. Follow the loop body with an if statement that compares n(n+1) this value to and displays a message that indicates whether the values are the same or different. What message do you think will be displayed? 2 • Following are two sample runs: ■ Sample Run 1: Enter an integer value greater than 1 : 5 sum of numbers from 1 to 5 = 15 ■ Sample Run 2: Enter an integer value greater than 1 : 0 Wrong input try again Enter an integer value greater than 1 : -5 Wrong input try again Enter an integer value greater than 1 : 1 Wrong input try again Enter an integer value greater than 1 20 sum of numbers from 1 to 20 = 210
Expert Answer:
Answer rating: 100% (QA)
Image of C program segment that meets the given requirem... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
In this question assume that p and q are atomic formulae. (a) Compare and contrast path formulae and state formulae in temporal logic. [4 marks] (b) Describe and contrast the meanings of F(G p) and...
-
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 Xerox machine in a shop is operated by a person who does other jobs too. The average service time for a job is 6 minutes per customer. On an average, in every 12 minutes one customer arrives for...
-
Give an example of a business transaction that has each of the following effects on the accounting equation: a. Increases an asset and increases a liability. b. Increases one asset and decreases...
-
Two pink slime producers, XL and IPSP, are located in an otherwise pastoral mountain town. Each producer emits 30 tons of ammonium hydroxide into the atmosphere each year. City planners wish to cut...
-
Calculate the solution to the following SDE: \[d X_{t}=\alpha\left(m-X_{t} ight) d t+\sigma d B_{t}\] with \(X_{0}=x\). The process satisfying this equation is called the meanreverting...
-
Bangor Products Co. obtained the following information from its records for April: Required: 1. Prepare, in summary form, the journal entries that would have been made during the month to record...
-
Let f(x)=x for rational x and f(x) = 0 for irrational x. (a) Calculate the upper and lower Darboux integrals for f on the interval [0, b]. (b) Is f integrable on [0,b]?
-
6. what is the area of the colored region, if the area of square BCEF is 64in A. 24in B. 28in C. 70in D. 19in
-
This case arose after Felix DeWeldon, a well-known sculptor and art collector, sold three paintings to Robert McKean in 1994. Felix DeWeldon declared bankruptcy in 1991. In 1992, DeWeldon, Ltd.,...
-
Zappos.com is a popular website known mainly for its discounted shoe sales. In 2012, a hacker hacked into the Zappos website in an effort to obtain the personal account information of Zappos...
-
Plaintiff contracted to install a boiler for defendant. After plaintiff had installed and tested the boiler, but before final payment to plaintiff had been made, defendant took custody of the boiler...
-
In 2016, a father of two minor children in Cuyahoga county, Ohio, filed a claim to determine custody of the children. At the pretrial, the father informed the magistrate he wanted to be named a legal...
-
On April 20, 1992, Daniel Hubbard (plaintiff), a potato farmer, and UTZ Quality Foods, Inc. (UTZ) (defendant), a potato chip manufacturer, entered an installment contract under which Hubbard agreed...
-
Susan has been investing $160,000 a year for the past 9 years into Sunshine in a Can, Inc. Today, as the sole shareholder, she sold Sunshine in a Can, Inc. for $2.6 million. What is her rate of...
-
Explain the term global capital markets. This chapter primarily discusses global equity markets. What other types of financial instruments are traded in these markets? How important are global...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-7. Ivan sold the following securities during the year and received a Form 1099-B that...
-
Rebecca and Walter Bunge have been married for 5 years. They live at 883 Scrub Brush Street, Apt. 52B, Las Vegas, NV 89125. Rebecca is a homemaker and Walt is a high school teacher. Rebecca's Social...
-
Kathy Kennedy (age 44) is a single taxpayer and she lives at 212 North Pine Way, Payson, AZ 85541. Her Social Security number is 467-98-9784. Kathy's earnings and income tax withholding as the...
-
Biologists have studied the running ability of the northern quoll, a marsupial indigenous to Australia. In one set of experiments, they studied the maximum speed that quolls could run around a curved...
-
In the swing carousel amusement park ride, riders sit in chairs that are attached by a chain to a large rotating drum. As the carousel turns, the riders move in a large circle with the chains tilted...
-
The chain on a bicycle turns the rear wheel via a gear cluster, as shown in Figure Q7.6. The gears vary in size; the smallest gear has a radius of 2.3 cm, the largest a radius of 6.0 cm. If we assume...
Study smarter with the SolutionInn App