C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 5.5, Problem 2E
(cin within a loop) Write and run a C++
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(python)
Study the following code, specifically the loop.
_sum = 10
for k in range (2, 20, 3):
_sum = _sum + (2*k)
if _sum > 100:
print("exceeded 100")
Now, rewrite the for loop (for k in range(2, 20, 3):)to be a while loop that accomplishes the same objective. You don't need to show/use the other lines.
PART 2 (Lab)
a. Write a C+ program that asks the user to enter N, the program should then output the
Fibonacci series. Use do-while loop to ask user to re-enter N if the user entered a number
below 2. Hint: The first two numbers in the Fibonacci series are 0 and 1.
F, = 0
F, = 1
Any Fibonacci number is equal to the summation of the two previous numbers
Fn = Fn-1+ Fn-2
Therefore,
F, + F, = 1+ 0 = 1
F, + F, = 1+1= 2
F4 = F3 + F2 = 2 +1 = 3
F2
....
FN =
FN-1 + FN-2
Enter N: 20
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765
b. Write a program that use loops to print the following patterns separately, one below the
other. In your code use for, while and do-while loops to generate the patterns, use one loop
for each question.
*
*********
**
*******
***
*****
****
***
*****
*
please help me thank you
Chapter 5 Solutions
C++ for Engineers and Scientists
Ch. 5.1 - (For review) List the three repetition statements...Ch. 5.1 - Prob. 2ECh. 5.1 - (For review) a. What’s the difference between a...Ch. 5.2 - (Practice) Rewrite Program 5.1 to print the...Ch. 5.2 - (Practice) Rewrite Program 5.4 to produce a table...Ch. 5.2 - (Conversion) Write a C++ program that converts...Ch. 5.2 - (Practice) An automobile travels at an average...Ch. 5.2 - (Numerical analysis) a. The following is an...Ch. 5.2 - Prob. 9ECh. 5.3 - Prob. 1E
Ch. 5.3 - (Conversion) a. Write a C++ program to convert...Ch. 5.3 - (Misc. application) a. The data in the following...Ch. 5.4 - (Practice) Write a for statement for each of the...Ch. 5.4 - (Desk check) Determine the value in total after...Ch. 5.4 - Prob. 5ECh. 5.4 - (Conversion) Write a C++ program to convert...Ch. 5.5 - (cin within a loop) Write and run a C++ program...Ch. 5.5 - Prob. 4ECh. 5.5 - Prob. 5ECh. 5.5 - Prob. 7ECh. 5.5 - (Program) Write a program that tests the...Ch. 5.5 - Prob. 14ECh. 5.5 - (Program) Write a program to simulate the rolling...Ch. 5.6 - (Misc. application) Four experiments are...Ch. 5.6 - (Electrical eng.) a. An electrical manufacturer...Ch. 5.6 - (Mathematical functions) Write a program that...Ch. 5.6 - Prob. 6ECh. 5.7 - (Practice) a. Using a do statement, write a...Ch. 5.7 - (Misc. application) a. Write a program that...Ch. 5.7 - (Misc. application) a. Write a program to reverse...Ch. 5.7 - Numerical analysis) Given a number, n, and an...Ch. 5.7 - (Numerical analysis) Here’s a challenging problem...Ch. 5 - (Probability) The probability that a phone call...Ch. 5 - (Mechanics) The deflection at any point along the...Ch. 5 - (Physics) A golf ball is dropped from an airplane....
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- . REDO EXERCISE using for loops, in C++ Write a program that uses while loops to perform the following steps:a. Prompt the user to input two integers: firstNum and secondNum(firstNum must be less than secondNum).b. Output all odd numbers between firstNum and secondNum.c. Output the sum of all even numbers between firstNum andsecondNum.d. Output the numbers and their squares between 1 and 10.e. Output the sum of the square of the odd numbers between firstNumand secondNum.f. Output all uppercase letters.arrow_forwardNeed help with this while loop question: (Please do this in Python programming) Using while True loop that: Prompts the user to enter a word; may use one input statement in function Calculates the number of words entered with an upper case first letter Presses (hits) the Enter/Returns key on the keyboard, without typing anything to signal the end of the loop Once the loops end, the function should return (not print) one of the following messages: "0 words were entered" "Words with upper case first letter = x', where x is the number of words maybe 0 if no words entered had an upper case first letter The output needs to look like this: (see image attached)arrow_forward(IN C LANGUAGE) Binary-Decimal / Decimal Binary . Between 0 and 255 a number will be decided randomly by computer. Then asks to user 3 times a random digit of binary value of the that number. If user enters wrong number for a digit program will select another random number and ask random times random digit. For example: Computer selected number as 163 ( Which is 10100011) What is the digit 2 (question 1/3) :User enter 1 CorrectWhat is the digit 4 (question 2/3) : User enter 0 CorrectWhat is the digit 7 (question 3/3) : User enter 0 CorrectUser finished the quest with 3 input .arrow_forward
- C++ pls (use only while-loop. using for-loop will not get any credit.) Ask user how many grades you have. then ask them to enter those grades (this is a outer while-loop), then each time validate a grade(this is inner while-loop), then when you got all valid grades, find the average.arrow_forward(Bar-Chart Printing Program) One interesting application of computers is drawing graphsand bar charts. Write a program that reads five numbers (each between 1 and 30). For each numberread, your program should print a line containing that number of adjacent asterisks. For example,if your program reads the number seven, it should print *******.arrow_forward-use loops and functions -Separate the implementation file from the definition file and header filearrow_forward
- 5. (Algebra: solve 2 X 2 linear equations) You can use Cramer's rule to solve the following 2 X 2 system of linear equation: ax + by = e cx + dy = f ● x = ed - bf bc ad y = af - ec ad bc - Write a program that prompts the user to enter a, b, c, d, e, and f and display the result. If ad- bc is 0, report that The equation has no solution. Enter a, b, c, d, e, f: 9.0, 4.0, 3.0, -5.0, -6.0, -21.0 Enter x is -2.0 and y is 3.0 Enter a, b, c, d, e, f: 1.0, 2.0, 2.0, 4.0, 4.0, 5.0 Enter The equation has no solutionarrow_forwardix) Write a C++ program that uses a 'for' loop to print the message "Hello" in the output 10 times in separate lines but the number of iterations of the loop must be 20. Use a counter inside the loop to show the number of iterations of the loop.arrow_forward(Phone key pads) The international standard letter/number mapping found on the telephone is shown below: 100 2 abc 3 def 4 ghi 5 ikl 6mno 7pgrs 8 tuv 9wxyz Write a program that prompts the user to enter a letter and displays its correspond- ing number.arrow_forward
- (Integers Added Together) Create a program that employs the for statement to sum a succession of integers in a single line. Assume that the first integer read defines the number of values that must be entered before the next one may be read. Your software should only read one value per input statement in order to avoid memory leaks. A typical input sequence may be 5 100 200 300 400 500 (or something like). where the number 5 signifies that the items after it are to be added together.arrow_forward(Sort three integers) Write a program that prompts the user to enter THREE integers and display the integers in decreasing order. Prepare your problem analysis and algorithm (pseudocode or flowchart) to plan your solution.arrow_forward(Printing a Table of ASCII Values) Write a program that uses a for statement to print atable of ASCII values for the characters in the ASCII character set from 33 to 126. The programshould print the decimal value, octal value, hexadecimal value and character value for each character.Use the stream manipulators dec, oct and hex to print the integer valuesarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
What Are Data Types?; Author: Jabrils;https://www.youtube.com/watch?v=A37-3lflh8I;License: Standard YouTube License, CC-BY
Data Types; Author: CS50;https://www.youtube.com/watch?v=Fc9htmvVZ9U;License: Standard Youtube License