(Practice) Write C++ statements for the following:
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
C++ for Engineers and Scientists
- Write four different C statements that each add 1 to integer variable xarrow_forwardWrite C++ expressions that are equivalent to the following mathematical formula. Assuming a, b, c, e, m1, m2, p, r, and x are separate variables. (a) b2 + 4ac (b) abc (c) 1 1+√1−x (d) 43πr2 (e) G = 4π2 a e3 p (m1+m 2) Write C++ statements for the following arithmetic expressions. Assume A, B, C, D, X, Y, and Z are separate variables. (a) A * C B * D ----------- + ----------- B + D A + D (b) C = A2 / B (c) result = √(ABC) (d) AX + BY4 - Z (e) 1 D answer = ----------- - ----------- 3 - C 3 + Barrow_forwardWrite C++ statements that accomplish the following. (6, 7)a. Declare int variables x and y. Initialize x to 25 and y to 18.b. Declare and initialize an int variable temp to 10 and a char variable ch to 'A'.c. Update the value of an int variable x by adding 5 to it.d. Declare and initialize a double variable payRate to 12.50.e. Copy the value of an int variable firstNum into an int variable temp Num.f. Swap the contents of the int variables x and y. (Declare additional variables, if necessary.)g. Suppose x and y are double variables. Output the contents of x, y, and the expression x + 12 / y - 18.h. Declare a char variable grade and set the value of grade to 'A'.i. Declare int variables to store four integers.j. Copy the value of a double variable z to the nearest integer into an int variable x.arrow_forward
- Write C++ statements that accomplish the following. (6, 7) Declare int variables x and y. Initialize x to 25 and y to 18. а. b. Declare and initialize an int variable temp to 10 and a char variable ch to 'A'. Update the value of an int variable x by adding 5 to it. C. d. Declare and initialize a double variable payRate to 12.50. Copy the value of an int variable firstNum into an int variable е. tempNum. f. Swap the contents of the int variables x and y. (Declare additional variables, if necessary.) g. Suppose x and y are double variables. Output the contents of x, y, and the expression x + 12 / y 18. h. Declare a char variable grade and set the value of grade to 'A'. i. Declare int variables to store four integers. j. Copy the value of a double variable z to the nearest integer into an int variable x.arrow_forwardA bag or cookies holds 50 cookies. The calorie information on the bag claims that there are 10 servings in the bag. Each serving equals 300 calories. The main function is given as following: void main () ( int cookies; cookies = cookiesAte (); caloriesConsumed = totalCalories (cookies); report (caloriesConsumed) ; Write functions that: a) asks the user input number of cookies he she actually ate. b) calculates the total calories were consumed c) reports how many total calories were consumed.arrow_forwardNeed this in C++ Combinatorics Inputs: positive integer n (number of letters in a password), positive integer m (number of digits in a password) Output: total number of possible passwords, total number of possible passwords if at most m digits in the password, total number of possible passwords if at most n letters in the password Note: Password is case sensitive.arrow_forward
- Write C++ statement(s) that accomplish the following: Declare variables x and y. Initialize x to 20 and y to 40. a. b. Declare and initialize an variable temp to 10.2 and a variable grade to 'A'. Update the value of an variable x by adding 5 to it. C. d. Declare and initialize a variable payRate to 12.50. e Swap the contents of the variables x and y. (Declare additional variables, if necessary) . Declare int variable id, then allow the user to enter a value . * Copy the value of a variable payRate to a new variable called a. h. Print this screen based on the notes required in the red line : id=(the value of id) x1=(the first value of x) x2=(the final value of x) a=(the value of a)arrow_forwardb) Write C++ statements that accomplish the following: 1. Declares int variables a and b. . Updates the value of an int variable y by adding 5 to it. i. Copies the content of an int variable y into an int variable z. iv. Declares int variables to store four integers. v. Outputs the content of a variable x and an expression 2 * x + 5 - y, where x and y are double variables. c) Suppose x, y and total are int variables and z is a double variable. What value is assigned to each variable after each statement executes? Assume x = 6, y = 10, and z = 28.2.arrow_forwardFlow chart for C programming that goes by this algorithim. 1) Tell the user to input those numbers 2) Output the very same numbers (unchanged) 3) Output the sum and difference of these numbers 4) Output the product of these numbers 5) Output the quotient of these numbers. Please take into account the special measures you need to take for 5) and give a reason for what you did in a comment in your program!arrow_forward
- (c) Simplify the following regular expression whenever possible (a+b)*a*)* . (d) Simplify the following regular expression whenever possible (b*(a*(ba)*)*)* .arrow_forward1. Write C Statements for the followings:arrow_forward-Program C 3. Negative Allergy by CodeChum Admin Whole numbers are great, but I think we should also pay attention to decimal numbers, too. So, how about we make a program that involves a lot of decimals? Instructions: Continuously ask for floating point values (decimal numbers) using the do…while() loop, sum them all up, and store the total into one variable. The loop shall only terminate for the following reasons: A negative decimal number is inputted (but still included in the total sum) The total sum reaches 100.0 or more Input 1. A series of float numbers Output The first multiple lines containing message prompts for float numbers. The last line contains the sum with 2 decimal places. Enter·a·number:·1.1 Enter·a·number:·1.2 Enter·a·number:·1.3 Enter·a·number:·1.4 Enter·a·number:·-1.0 Sum·=·4.00arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning