Concept explainers
Explanation of Solution
Given
//Include the header files
#include <iostream>
using namespace std;
//Main function
int main()
{
//Declare the variables
int integer1, integer2;
double result;
//Intialize the variables
integer1 = 19;
integer2 = 2;
/*Divide the integers and store the result in a variable*/
result = integer1 / integer2;
//Print the result
cout << result << endl;
/*Divide the integers by type-casting the first integer and store the result in a variable*/
result = static_cast<double>(integer1) / integer2;
//Print the result
cout << result << endl;
/*Divide the integers by type-casting the both integers and store the result in a variable*/
result = static_cast<double>(integer1 / integer2);
//Print the result
cout << result << endl;
//Return the statement
return 0;
}
Explanation:
- The first process in the program is to include the required header files...
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Starting Out with C++ from Control Structures to Objects (9th Edition)
- Write a program in c that has three float variable (place random values in them) and that will call thefunctions below using these variables as arguments.Create a function named pizza that takes three float arguments and returns the lowest value of them.Call the function pizza on the three variables and output the function return to the screen.Create a function named burger that takes three float arguments and returns the highest value of them.Call the function pizza on the three variables and output the function return to the screen.Create a function named hotdog that takes three float arguments and returns the middle value of them.Call the function pizza on the three variables and output the function return to the screen.arrow_forwardJAVA CODE PLEASE 2. Functions With Parameters and Return Values Practice ll by CodeChum Admin Create a function named compare that receives three integer arguments and compares them. Return the integer with the greatest value. In the main function, create a program that asks for three integer user inputs and assign it to an integer variable. Call the compare function by passing the three integer variables in the actual parameters and assign the returned value to a variable. On the next line, print the value assigned to the variable. Input 1. One line containing the first integer 2. One line containing the second integer 3. One line containing the third integer Output Enter·number·1:·1 Enter·number·2:·2 Enter·number·3:·3 Greatest:·3arrow_forwardSuppose you are a surveyor. Your job requires you to study some maps that give distances in kilometresand sometimes in miles. You prefer to deal in kilometers. Write a program that performs necessaryconversion by using pass by reference and pass by value.Formula: kilometers X 0.6214 = Miles Using pointers C++ programmingarrow_forward
- #include <stdio.h>void cubeByReference( int *nPtr ); // function prototypeint main( void ){ int number = 5; // initialize number printf("The original value of number is %d", number ); // pass address of number to cubeByReference cubeByReference( &number ); printf("\nThe new value of number is %d\n", number );} // end main void cubeByReference( int *nPtr ){ *nPtr = *nPtr* *nPtr* *nPtr;} passing argument by reference - We modify the code above 1- define a second argument (example "int number2 = 9") and a pointer to it 2- define a second function (addByReference) that adds number2 to number - passing both arguments by reference 3- print-out the result (that is in number) Upload the output and .c codearrow_forwardIn c++ only Please create a class multiplication with three overloaded functions to multiply two or three integers or two double literels. Please provide output and code screenshotarrow_forwardWrite a C++ program using C++ Classes, Arrays, Vectors, Functions, Pointers, Advance File IO and C++ STL to do the following: Display a Main Menu below with Menu options and your company heading to calculate customer total and print receipt. Also your name must be in the programming code A. Read in order from order file below B. Calculate and display total tax (NYC is 8.85%) C. Display customer discounts D. Print out customer receipt to screen and file. E. Exit order.txt Items List price Discount Quantity LG TV 599.99 16% 3 Phone Galaxy S23 997.88 25% 2 External Hard Drive 89.99 20% 4 Laptop 479.55 25% 1 iPhone 900.00 20% 3 NY Sale Tax 8.85% You must use C++ classes and functionsarrow_forward
- Question 3 Write a program in C, which simulates the game of connect 4, representing the board with coloured tiles, by means of matrices, where the player can choose whether to play with the computer and the computer represents player 2 or with another person, where at the end it shows the winner, the loser or if there was a draw. . Full explain this question very fast solution sent mearrow_forwardQuestion Write a complete C++ program that apply menu-driven style. Three options that should be created and executed are: Function 1 This user-defined function can accept four (4) parameters which is integer numbers. By using passing parameter by reference this function can change the original position of four numbers and return the multiplication result of four numbers. The changes and additional result are displayed in main() program. Example : 2 4 6 8 (original) , 8 6 4 2 (position changed) Multiplication result: 384 Note : Cannot use array. Function 2 This user-defined function can accept two (2) string which is array of character data type. In this function, use built-in function to compare this two string. Display the result whether both string similar or not similar in function 2. Example : char s1[20] is Drone char s2[20] is Drone , Output : similar Note : Cannot use pointer or string data type. Exit from the program. Notes: Refer Figure 1 below. The input (bold) can be…arrow_forwardrite a menu driven C++ program to do the following:1. Read Employees information from a data file: Name, Hrs work, rate of pay2. Write the following data to an output text file. Name, Hrs work, rate of pay and Gross pay and net pay (tax 21%)3. Print employees checks with net pay.Must use Classes, Functions, Advance Files IO, pointers, arrays and C++ STLarrow_forward
- Solve the problem in C++ (Financial application: compute the future investment value) Write a function that computes future investment value at a given interest rate for a specified number of years. The future investment is determined using the formula in Programming Exercise 2.23. Use the following function header: double futureInvestmentValue( double investmentAmount, double monthlyInterestRate, int years) For example, futureInvestmentValue(10000, 0.05/12, 5) returns 12833.59. Write a test program that prompts the user to enter the investment amount (e.g., 1000) and the interest rate (e.g., 9%) and prints a table that displays future value for the years from 1 to 30, as shown below: The amount invested: 1000 Annual interest rate: 9 Years Future Value 1 1093.80 2 1196.41 ... 29 13467.25 30 14730.57arrow_forward1 - Nuclear Power Plant (python) The nuclear powerplant at Threeyedfish will automatically run a program to print a warning message when the reactor core becomes unstable. The warning message reads: NUCLEAR CORE UNSTABLE!!! Quarantine is in effect. Surrounding hamlets will be evacuated. Anti-radiationsuits and iodine pills are mandatory. Since the message contains crucial information, it should be printed three times. To do this, write a function that prints this message. This function has to be used three times.arrow_forwardstruct date{ int day; int month; int year; }; Write a function named void increaseDay(struct date *d) that increases the value of a variable of struct date type with integer year, month, and day members by one day. Write a function named void decreaseDay(struct date *d) that decreases the value of a variable of struct date type with integer year, month, and day members by one day. Write a C program that reads from the user a date in d/m/y format and the amount of increase or decrease as an integer. Display the new date in d/m/y format. You may call related functions as many as given increase or decrease value. Note 1: You do not need to consider leap years. Use always 28 days for month February. Note 2: Do not modify the function prototypes. Sample Input1: Sample Output1: 12/8/1990 -5 7/8/1990 Sample Input2: Sample Output2: 26/2/2005 5 3/3/2005 Sample Input3: Sample Output3: 29/12/1998 7 5/1/1999…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education