Concept explainers
What will each of the following
A) x = 2;
y = x++;
cout << x << " " << y;
B) x = 2;
y = ++x;
cout << x << " " << y;
C) x = 2;
y = 4 ;
cout << x++ << " " << − −y;
D) x = 2;
y = 2 * x++;
cout << x << " " << y;
E) x = 99;
if (x++ < 100)
cout "It is true! \n";
else
cout << "It is false! \n";
F) x = 0;
if (++x)
cout << "It is true! \n";
else
cout << "It is false! \n";
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Starting Out with C++: Early Objects (9th Edition)
Additional Engineering Textbook Solutions
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Concepts Of Programming Languages
Java: An Introduction to Problem Solving and Programming (8th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
Electric Circuits. (11th Edition)
- Java GUI (Calculator) Programarrow_forwardProgram to Analyze Student Performance • The program should request the user to input grades for 6 subjects (assume a scale of 0 to 120). • Calculate the weighted average grade for the semester, where each subject has a different weight (weights are: 4, 3, 3, 2, 2, 1 for subjects 1 to 6 respectively). • Display the weighted average grade to the user. • Provide a performance category based on the following criteria: Below 30: Insufficient • 30 to 49: Marginal • 50 to 69: Satisfactory • 70 to 89: Proficient · • 90 to 120: Outstanding Additionally, if any subject's grade is below 50, display a message recommending additional attention to that subject. Write a C++ program following these requirements and include comments for clarity and self-documentation.arrow_forwardText-based adventure game: Pretend you are creating a text-based adventure game. At different points in the game, you want the user to select to fight, run, or hide from certain enemies. Modify the application below (week3.py) so that the selection variable is sent as an argument into the choice() function. The user should enter 1 to fight, 2 to run, or 3 to hide in the main(). The choice() function should print one of the three options. You will need to add an if statement in the choice() function to make the correct selection.arrow_forward
- Task 2: Using Function-Temperature Table The formula for converting a temperature from Fahrenheit to Celsius is: 5 C = (F-32) Where F is the Fahrenheit temperature and C is the Celsius temperature. Write a function named Celsius that accepts a Fahrenheit temperature as an argument. The function should return the temperature, converted to Celsius. Demonstrate the function by calling it in a loop that displays a table of Fahrenheit temp. 0 through 20 and there Celsius equivalents. The program should display the number of numbers found in the file, the sum of the numbers, and the average of the numbers.arrow_forwarduse C++ languagearrow_forwardcomputer programmingarrow_forward
- Domino's Time Function Name: dominosTime() Parameters: N/A Returns: None Description: During the summer, you ordered a lot of food from Domino's. Pizzas are $12, an order of pasta is $6, and chicken wings are $8. Write a function that asks the user how many of each food item they would like, and then print a response telling them what their order to- tal will be. The order total should be an integer. >>> dominosTime() How many pizzas do you want? 3 How many orders of pasta do you want? 2 How many orders of chicken wings do you want? 2 By ordering 3 pizzas, 2 orders of pasta, and 2 orders of chicken wings, your order total comes to $64.arrow_forwardMP: Create a program using structures to compute for the final grade of a student with the following conditions; Prelim grade 30% Midterm grade 30% Finals grade 40% See screenshot below for your reference: Name: Juan Dela Cruz Prelim Grade: 89 Midterm Grade: 82 Finals Grade: 77 Student Name Final Grade : Juan Dela Cruz 82.10 Name: Bill Gates Prelim Grade: 77 Midterm Grade: 84 Finals Grade: 90 Student Name Final Grade : Bill Gates 84.30arrow_forwardNeeds to be done in C# language. Problem Write a program that computes and displays the charges for a patient’s hospital stay. First, the program should ask if the patient was admitted as an in-patient or an out-patient. If the patient was an in-patient, the following data should be entered: • The number of days spent in the hospital• The daily rate• Hospital medication charges• Charges for hospital services (lab tests, etc.) The program should ask for the following data if the patient was an out-patient: • Charges for hospital services (lab tests, etc.)• Hospital medication charges The program should use two overloaded functions to calculate the total charges. One of the functions should accept arguments for the in-patient data, while the other function accepts arguments for out-patient information. Both functions should return the total charges. Input Validation: Do not accept negative numbers for any data.arrow_forward
- Visual Basic For tax purposes an item may be depreciated over a period of several years, n.With the straight line method of depreciation, each year the item depreciates by 1/nth of itsoriginal value. With the double declining balance method of depreciation, each year the itemdepreciates by 2/nths of its value at the beginning of that year. (In the final year it is depreciatedby its value at the beginning of the year.)Write a program that performs the following tasks:1.1 Request a depreciation of the item, the year of purchase, the cost of the item, the number ofyears to be depreciated (estimated life), and the method of depreciation. The method ofdepreciation should be chosen by clicking on one of two buttons.1.2 Display a year by year description of the depreciation.arrow_forwardVisual Basic For tax purposes an item may be depreciated over a period of several years, n.With the straight line method of depreciation, each year the item depreciates by 1/nth of itsoriginal value. With the double declining balance method of depreciation, each year the itemdepreciates by 2/nths of its value at the beginning of that year. (In the final year it is depreciatedby its value at the beginning of the year.)Write a program using Visual Basic that performs the following tasks:1.1 Request a depreciation of the item, the year of purchase, the cost of the item, the number ofyears to be depreciated (estimated life), and the method of depreciation. The method ofdepreciation should be chosen by clicking on one of two buttons.1.2 Display a year by year description of the depreciation.arrow_forwardC++ programming Chapter(s) Covered: Chapter 1-8 Concepts tested by the program: Working with one dimensional parallel arrays Use of functions Use of loops and conditional statements Project Description The Lo Shu Magic Square is a grid with 3 rows and 3 columnsshown below. The Lo Shu Magic Square has the following properties: The grid contains the numbers 1 – 9 exactly. Each number 1 – 9must not be used more than once. So, if you were to add up thenumbers used, The sum of each row, each column and each diagonal all add upto the same number, Write a program that simulates a magic square using 3 onedimensional parallel arrays of integer type. Each one the arrays corresponds to a row of the magicsquare. The program asks the user to enter the values of the magicsquare row by row and informs the user if the grid is a magicsquare or not. See the sample outputs for more clarification. Project Specifications Input for this project: Values of the grid (row by row) Output for this…arrow_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 LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage