(Practice) Write a for statement for each of the following cases:
a. Use a counter named i that has an initial value of 1, a final value of 20, and an increment of 1.
b. Use a counter named icount that has an initial value of 1, a final value of 20, and an increment of 2.
c. Use a counter named j that has an initial value of 1, a final value of 100, and an increment of 5.
d. Use a counter named icount that has an initial value of 20, a final value of 1, and an increment of -1.
e. Use a counter named icount that has an initial value of 20, a final value of 1, and an increment of -2.
f. Use a counter named count that has an initial value of 1.0, a final value of 16.2, and an increment of 0.2.
g. Use a counter named xcnt that has an initial value of 20.0, a final value of 10.0, and an increment of -0.5.
Trending nowThis is a popular solution!
Chapter 5 Solutions
C++ for Engineers and Scientists
- Construct a truth table and use it to determine which of the following statements is equivalent to the statement ∼p∧∼q.arrow_forward(Practice) Determine the value of the following expressions, assuming a=5,b=2,c=4,d=6,ande=3: a.abb.a!=bc.db==cbd.ac!=dbe.db==cef.!( ab)g.!( abc)h.!( cba)i.bcaarrow_forward(c) The following expression is a postfix string for an arithmetic expression. 16| -2 | 4| * | 21 | 17|-|7|9|+|7|5|+ But it contains one or more errors. Identify the error(s) and provide your own correction, which should be as simple as possible. Then produce the equivalent expression in infix form based on your correction. (The vertical bars serve only to separate the items in the expression, and do not form parts of the expression.) Sarrow_forward
- (b) Q.2 (a) As a teacher, it is quite a hassle to grade your students one by one according to thei scores. Based on the flowchart in Figure Q.2 (a), write a MATLAB code to enter the name of your students with their scores into the system so that you can get the scores automatically. The system should print out the list of students' names with their score and grade as shown in Figure Q.2(b). start 1=number of students name[i]=student i's name score[i] = student i's score yes i>0 I no 19 print all end i=i-1 no 0=90 [yes gred[i] = 'A' no score >-80 yes gred='B' Student1 Student2 Student3 Student4 Student5 Figure Q.2(a) Student's score: 84 Student's name: Student3 no Student's score: 76 Student's name: Student4 Student's score: 65 Student's name: Student5 Enter the number of students: 5 Student's name: Studentl Student's score: 92 Student's name: Student2 score >=70 yes gred='C Marks 92.00 84.00 76.00 65.00 45.00 Figure Q.2(b) no Student's score: 103 Out of allowed range. Enter again: 45…arrow_forwardCreate a truth table for the following expressions a. AB'C + A'Barrow_forward(For review) a. What’s the difference between a pretest and posttest loop? b. If the condition being tested in a pretest loop is false, how many times are statements in the loop executed? c. If the condition being tested in a posttest loop is false, how many times are statements in the loop executed?arrow_forward
- (python) Count the number of loops (can be an infinite loop): for i in range(10, 100, 10): if i % 2 == 0: i += 10 print(i)arrow_forward(NOTE: use onlinegdp as C langugage program) prove a screen shot of the ouput. Perform the following: 1. Write an essay "Today I have learned..." about module 6. 2. Write a C program that will determine if the input number is even or odd using if-else statement. Scenario 1 Sample Output: Enter a number: 2021 Remark: ODD Scenario 2 Sample Output: Enter a number: 2022 Remark: EVEN Your Source Codes Here: Your Screenshot of Output Here: 3. Write a C program that will accept input values from 1-7 and will display the days of the week using switch statement. Scenario 1 Sample Output: Enter a number: 1 Day: Monday Scenario 2 Sample Output: Enter a number: 2 Day: Tuesday Scenario 3 Sample Output: Enter a number: 3 Day: Wednesday Scenario 4 Sample Output: Enter a number: 4 Day: Thursday Scenario 5 Sample Output: Enter a number: 5 Day: Friday Scenario 6 Sample Output: Enter a number: 6 Day: Saturday Scenario 7 Sample Output: Enter a number: 7 Day: Sunday Scenario 8 Sample…arrow_forwardState whether each statment is true or false. If the answer is false, explain why? "The address operator & can be applied only to constants and to expressions."arrow_forward
- Write programs for the following problem statements.a) Write a postcondition, event-controlled loop (i.e., a while loop), using a break statement,that prints the numbers 8, 14, 20, 26, 32, and 38 to the terminal (one per line). b) Write a postcondition, event-controlled loop (i.e., a while loop), using a flag variable, that prints the numbers 8, 14, 20, 26, 32, and 38 to the terminal (one per line). c) Write a counter-controlled loop (i.e., a for loop), that prints the numbers 8, 14, 20, 26, 32, and 38 to the terminal (one per line). d) Re-write a), b) and c) so that they print the numbers 38, 32, 26, 14, and 8 to the terminal (one per line). e) Re-write a), b), c), and d) so that they print the numbers to the terminal on the same line separated by spaces.arrow_forwardprint to the screen the address of the variable x * Your answerarrow_forward(Mechanics) The deflection at any point along the centerline of a cantilevered beam, such as the one used for a balcony (see Figure 5.15), when a load is distributed evenly along the beam is given by this formula: d=wx224EI(x2+6l24lx) d is the deflection at location x (ft). xisthedistancefromthesecuredend( ft).wistheweightplacedattheendofthebeam( lbs/ft).listhebeamlength( ft). Eisthemodulesofelasticity( lbs/f t 2 ).Iisthesecondmomentofinertia( f t 4 ). For the beam shown in Figure 5.15, the second moment of inertia is determined as follows: l=bh312 b is the beam’s base. h is the beam’s height. Using these formulas, write, compile, and run a C++ program that determines and displays a table of the deflection for a cantilevered pine beam at half-foot increments along its length, using the following data: w=200lbs/ftl=3ftE=187.2106lb/ft2b=.2fth=.3ftarrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr