a.
Explanation of Solution
Given: The values of the variables, x = 2, y = 3, and z = 1, are assigned to the expression, x+2 / 6+y.
To find: The result of the expression, x+2 / 6+y, if x = 2, y = 3, and z = 1 .
Solution:
Precedence of the operator defines the grouping of words within an expression and defines how to interpret an expression. Many operators precede over others; for example, the operator of multiplication has a greater precedence than the operator of addition...
b.
Explanation of Solution
Given: The values of the variables, x = 2, y = 3, and z = 1, are assigned to the expression, y-3 * z+2.
To find: The result of the expression, y-3 * z+2, if x = 2, y = 3, and z = 1 .
Solution:
Precedence of the operator defines the grouping of words within an expression and defines how to interpret an expression. Many operators precede over others; for example, the operator of multiplication has a greater precedence than the operator of addition...
c.
Explanation of Solution
Given: The values of the variables, x = 2, y = 3, and z = 1, are assigned to the expression, z – (x+z) % 2 + 4.
To find: The result of the expression, z – (x+z) % 2 + 4, if x = 2, y = 3, and z = 1 .
Solution:
Precedence of the operator defines the grouping of words within an expression and defines how to interpret an expression. Many operators precede over others; for example, the operator of multiplication has a greater precedence than the operator of addition...
d.
Explanation of Solution
Given: The values of the variables, x = 2, y = 3, and z = 1, are assigned to the expression, x-2*(3+z)+y.
To find: The result of the expression, x-2*(3+z)+y, if x = 2, y = 3, and z = 1 .
Solution:
Precedence of the operator defines the grouping of words within an expression and defines how to interpret an expression. Many operators precede over others; for example, the operator of multiplication has a greater precedence than the operator of addition...
e.
Explanation of Solution
Given: The values of the variables, x = 2, y = 3, and z = 1, are assigned to the expression, y++ + z-- + x++.
To find: The result of the expression, y++ + z-- + x++, if x = 2, y = 3, and z = 1 .
Solution:
Prefix operation like ‘++var’ or ‘--var', having property that the value is first incremented or decremented by 1, then it returns the value...
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Computer Science: A Structured Programming Approach Using C, Third Edition
- Assuming the following code: int x = myfunction1(); /* arbitrary value */ int y = myfunction2(); /* arbitrary value */ int z = myfunction3(); /* arbitrary value */ //convert to double double dx = (double) x; double dy = (double) y; double dz = (double) z; unsigned ux = x; unsigned uy = y; The following statement always evaluates to 1 (True or False): dx - dy == (double) (x-y) Question 3 options: True Falsearrow_forwardWrite two cin statements to get input values into birthMonth and birthYear. Then write a statement to output the month, a dash, and the year. End with newline. Remember that outputting 'endl' outputs a newline.Ex: If the input is 1 2000, the output is:1-2000 #include <iostream>using namespace std; int main() { int birthMonth; int birthYear; /* Your solution goes here */ return 0;}arrow_forwardAssuming the following code: int x = myfunction1(); /* arbitrary value */ int y = myfunction2(); /* arbitrary value */ int z = myfunction3(); /* arbitrary value */ //convert to double double dx = (double) x; double dy = (double) y; double dz = (double) z; unsigned ux = x; unsigned uy = y; The following statement always evaluates to 1 (True or False): (dx + dy) + dz == dx + (dy + dz) True Falsearrow_forward
- Write a single scanf statement that reads user-entered time (three integers) and discards the user-entered characters between the numbers, in order, for hour (hh), minute (mm), and second (ss). For example, the user may enter the time as 12:23:21 or 12 23 21 or 12, 23, 21.arrow_forwardPrompt the user to enter in the three number that define a quadratic ??2+??+?=0ax2+bx+c=0, that is prompt the user to enter in numbers a, b, c. Compute the two solutions to the quadratic (i.e., solve for x). We will assume the user inputs numbers that result in a positive discriminant. Display the results.arrow_forwardC++ help Please! Print either "Fruit", "Drink", or "Unknown" (followed by a newline) depending on the value of userItem. Print "Unknown" (followed by a newline) if the value of userItem does not match any of the defined options. For example, if userItem is GR_APPLES, output should be: Fruit code provided: #include <iostream>using namespace std; int main() { enum GroceryItem {GR_APPLES, GR_BANANAS, GR_JUICE, GR_WATER}; GroceryItem userItem; userItem = GR_APPLES; /* Your solution goes here */ return 0;}arrow_forward
- A switch statement can evaluate the following variable types? A.) integer B.) string C.) char D.) enum E.) All of the abovearrow_forwardCode C was used to make this Can this be done in a form of a flowchart please? 1. Prompt the user and read in the number of a team playing the current game, i.e. Team 1,Team 2, Team 3, etc.2. Prompt the user and read in the number of the opponent team. It is probably helpful to think of the first team as the home team for this game, and the second team as the away team. 3. Prompt the user and read in a team’s score for the current game. Use the team’s number when asking for the score in your printf statement.4. Prompt the user and read in the opponent’s score for that game. Again, use the opponent’s team number when asking for the score.5. Notify the user and repeat steps 3 and 4 in the case that the user enters a negative value.6. Calculate the points earned by each team and add it to a cumulative score. A win is worth 3 points, a draw is worth 1 point and a loss is zero points. Also update the amount of games played by each team and their goals for and against. 7. Print to the…arrow_forwardI'm stuck on this problem, and here's what I'm stumped on: Meadowdale Dairy Farm sells organic brown eggs to consumers in the surrounding area. For a dozen eggs, it charges $3.25, and for individual eggs that are not part of a dozen, it charges 45 cents each egg. Using the following phrasing, write a program that prompts a user to enter the number of eggs in the order and then displays the amount owed along with a detailed explanation of why the amount is due: You placed an order for 27 eggs. There are 2 dozen eggs at $3.25 per dozen and 3 loose eggs at 45 cents each, which adds up to a total of $7.85.arrow_forward
- Suppose that classStanding is a char variable, gpa and dues are double variables. Write a switch expression that assigns the dues as following: If classStanding is 'f', the dues are $150.00; if classStanding is 's', (if gpa is at least 3.75, the dues are $75.00; otherwise dues are 120.00); if classStanding is 'j', (if gpa is at least 3.75, the dues are $50.00; otherwise dues are $100.00); if classStanding is 'n', (if gpa is at least 3.75, the dues are $25.00; otherwise dues are $75.00). (Note that the code 'f' stands for first year students, the code 's' stands for second year students, the code 'j' stands for juniors, and the code 'n' stands for seniors.)arrow_forwardQuestion 5 What is the output of the following code segment? int num cin>>x; = 20, 5, X; if (x >= 2*num) y+=1; else if (x >= num) y+=2; if (xarrow_forwardMeadowdale Dairy Farm sells organic brown eggs to local customers. It charges $3.25 for a dozen eggs, or 45 cents for individual eggs that are not part of a dozen. Write a program that prompts a user for the number of eggs in the order and then display the amount owed with a full explanation using the following wording: You ordered 27 eggs. That’s 2 dozen at $3.25 per dozen and 3 loose eggs at 45 cents each for a total of $7.85. So far everything is right but something in my equations is causing my ouput to show up as 45.0arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage