2. Write a C program that prompts the user to enter a number. If the number...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
2. Write a C program that prompts the user to enter a number. If the number is an even number other than a multiple of 8 (8, 16, 24, 32 ...), the program will calculate the square of the number and print it on the screen, and ask for another number. If the number is odd, other than a multiple of 7 (7, 14, 21 ...), the program will calculate the cube of the number, print it on the screen, and then ask for another number. The program will continue until the user enters the number 0 (zero). You should use for-loop structure with "continue" and "break" statements. Hints: • The program should use the statement "continue", whenever the user input is a multiple of 7 or 8, in order to skip to the next iteration of the loop. The program should use the statement "break" when the user input is equal to 0 (zero). 2. Write a C program that prompts the user to enter a number. If the number is an even number other than a multiple of 8 (8, 16, 24, 32 ...), the program will calculate the square of the number and print it on the screen, and ask for another number. If the number is odd, other than a multiple of 7 (7, 14, 21 ...), the program will calculate the cube of the number, print it on the screen, and then ask for another number. The program will continue until the user enters the number 0 (zero). You should use for-loop structure with "continue" and "break" statements. Hints: • The program should use the statement "continue", whenever the user input is a multiple of 7 or 8, in order to skip to the next iteration of the loop. The program should use the statement "break" when the user input is equal to 0 (zero).
Expert Answer:
Answer rating: 100% (QA)
PROBLEM STATEMENT 2 Write a C program that prompts the user to enter a number If the number is an ev... View the full answer
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
The economic environment of our country currently does not lend itself to being able to successfully run capital campaigns. In a two page document, research and identify 2 successfully capital...
-
Name two endocrine glands (or regions) that are important in the stress response, and explain why they are important.
-
The great white shark can have a mass as great as 3000 kg. Suppose such a shark is cruising the ocean when it spots a meal below it: a 200.0-kg fish swimming horizontally at 8.00 m/s. The shark...
-
Suppose you are in an elevator that is accelerating upward at \(1 \mathrm{~m} / \mathrm{s}^{2}\). (a) Draw a free-body diagram for your body. (b) Determine the magnitude of the force exerted by the...
-
1. The FCPA distinguishes between so-called facilitating payments and more serious activities. Do you think such a distinction and the related penalties for violations under the Act make sense from...
-
which a disk A of radius r rotates about a fixed vertical axis with angular displacement q1. A bar B of length h is pinned to A such that the axis of rotation is a radial line of A. (Note this is a...
-
Identify by letter the curve you would expect in the titration of a solution containing (a) Disodium maleate, Na 2 M, with standard acid. (b) Pyruvic acid, HP, with standard base. (c) Sodium...
-
OSB Ltd. Wants to buy a new digital projection system. Two models are available as follows: Both models are expected to boost revenue by $20,000/year. System 1 will last 3 years and cost $2,000 per...
-
Not long ago, snowboarding seemed to be on pace to pass skiing as the countrys favorite way to zoom down snowy mountains, but the sports growth has cooled off in recent years.32 Your task: Research...
-
H a : 156.2, n = 225, x = 155.5, = 29. Find the value of the standard score, z, and determine whether the alternative hypothesis is supported at a 0.05 significance level.
-
For 10 pairs of sample data, the correlation coefficient is computed to be r = -1. What do you know about the scatterplot?
-
A time-series process of the form \(y_{t}=\alpha+y_{t-1}+v_{t}, v_{t} \sim N\left(0, \sigma^{2} ight)\) can be rearranged as \(y_{t}-y_{t-1}=\) \(\Delta y_{t}=\alpha+v_{t}\). This shows that...
-
In a study of casino size (square feet) and revenue, the value of r = 0.445 is obtained. Find the value of r2. What does that value tell us?
-
What is organizational behavior? Why is it important for managers and aspiring managers to study OB using a strategic approach? Can the study of a field such as psychology substitute for a strategic...
-
TRUE OR FALSE: 1. Banks with a significantly large share of fixed-interest rate home loans are less exposed to interest rate risks. 2. Although Australian banks are pretty big, they are not...
-
Write a program to display a recursive tree as shown in Figure 18.20. 1 Enter an order: Enter an order: Enter an order: Enter an order: 5 (b) (a)
-
Write a program that draws two filled circles with radius 15 pixels, centered at random locations, with a line connecting the two circles. The distance between the two centers is displayed on the...
-
Write the following method that shuffles an ArrayList: public static void shuffle(ArrayList list)
-
The mean height of American males is 69.5 inches. The heights of the 43 male U.S. presidents* (Washington through Obama) have a mean 70.78 inches and a standard deviation of 2.77 inches. Treating the...
-
The "fun size" of a Snickers bar is supposed to weigh 20 grams. Because the penalty for selling candy bars under their advertised weight is severe, the manufacturer calibrates the machine so the mean...
-
According to the American Community Survey, the mean travel time to work in Collin County, Texas, in 2013 was 27.5 minutes. The Department of Transportation reprogrammed all the traffic lights in...
Study smarter with the SolutionInn App