Integer division:
When both operands are integer data types, the resultant statement will be in integer division which means the outcome of the division will also be an integer data type. If there is a remainder, it must be ignored.
Example:
The example for the integer division is as follows:
double value;
value = 5 / 3;
In the above example, the outcome of the “5” by “3” is stored in the variable “value”. The value “1” is stored in the variable “value” because both “5” and “3” are integers, so the decimal part of the result must be truncated.
Floating-point division:
When both operands are floating-point or any one of the operand is a floating-point, the resultant statement will be in floating-point division, which means the outcome of the division will be a floating-point data type.
Example:
The example for the floating-point division is as follows:
double value;
value = 5.0 / 3;
In the above example, the result of the “5.0” by “3” is stored in the variable “value”. The value “1.6667” is stored in the variable “value”, because “5.0” is the floating-point data type and “3” is an integer data type, so the result has a floating-point value.
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
- Usage: mortgagepmt [-s] -r rate [-d downpayment] price In this assignment, you are asked to do a mortgage payment calculation. All information needed for this will be passed to the program on the command line. There will be no user input during the execution of the program. You will need a few pieces of information. The price of the home and the amount of the down payment. You will also need to know the interest rate and the term of the mortgage. To figure your mortgage payment, start by converting your annual interest rate to a monthly interest rate by dividing by 12. Next, add 1 to the monthly rate. Third, multiply the number of years in the term of the mortgage by 12 to calculate the number of monthly payments you’ll make. Fourth, raise the result of 1 plus the monthly rate to the negative power of the number of monthly payments you’ll make. Fifth, subtract that result from 1. Sixth, divide the monthly rate by the result. Last, multiply the result by the amount you want to borrow.…arrow_forward/ create the following functions: GetInteger - returns an integer DONE GetDouble - returns a double CheckInteger (called from GetInteger) - checks the range of an integer CheckDouble(called from GetDouble) - checks the range of a doubleCalculateSum - overloaded for integers and doubles as parameters DONE CalculateProduct - overloaded for integers and doubles as parameters DONE ShowSums - shows the sums of integers and the sum of doubles ShowProducts - shows the products of integers and the product of doubles. if you can create a function ShowInstructions that passes the type (integer or double) as a string. ShowInstructionsIntegers and ShowInstructionsDoublesarrow_forwardCreate a function called surprise_function () which takes in two integers and adds them together. You will then create the following overloaded versions, which should do different things based on the data type passed in: Data Type Operation Integer Addition Float Division Double Modulus Char Concatenation (Return as String) Boolean Result of AND You should prompt the user for what data type they want to enter, then ask for two values of that data type. Then, call surprise_function (), pass in the values, store the result in an appropriate variable, then print the variable. Note: You must make overloaded functions for this assignment – they must all be called surprise_function (). You can not create unique, non-overloaded functions like surprise_function_booleans(). Dynamic Arrays for C++ . There are several popular compilers, but there are a few key differences between what they will and won’t allow you to do in C++. In some compilers, the following code is…arrow_forward
- Thank you soo much!arrow_forwarddef division_calculator(a, b): ''' Question 4 You are asked to write a small division calculator, where you are taking 'a' as dividend and 'b' as the divider. You will need to return both the quotient and the remainder. Your returned result should be the: "a is divided by b, with the quotient equals 'quotient' and remainder equals 'remainder'" Note: You must use f-string to do this question. Args: a (int), b (int) Returns: string >>> division_calculator(3, 1) "3 is divided by 1, with the quotient equals 3 and remainder equals 0." ''' # print(division_calculator(9, 3))arrow_forwardwrite the definition statement for a variable fltPtr. The variable should be a pointer to a floatarrow_forward
- Which concept is used in the following codearrow_forwardthe code CREATE FUNCTION Calculate_Monthly_Payment( @mortage_amount BIGINT , @apr DECIMAL(18, 6) , @years INT)RETURNS DECIMAL(18, 6)ASBEGIN /* A = P (i + i (1+i) −1 n ) where: A = Monthly Payment Amount P = Principle (Initial) Mortgage Amount i = APR / 12 = Monthly Interest Rate n = years * 12 = Total Number of Payments */ -- Calculate monthly interest rate DECLARE @i DECIMAL(18, 6) SET @i = @apr / 12 DECLARE @n INTEGER SET @n = @years * 12 RETURN (@mortage_amount *@i * POWER(1+@i,@n)) / (POWER(1+@i, @n) - 1) END isn't working it shows that ERROR: syntax error at or near "@" LINE 3: @mortage_amount BIGINT ^ SQL state: 42601 Character: 48arrow_forwardWrite a set of functions that calculate the cost of movie tickets for a family. These functions should use a pass-by-reference variable that accesses the double running_total variable in main(). Using a loop, keep displaying the ticket prices for each age group: Something like: Model Hall Movie Ticket Box Office Under Age 3 (free) Ages 3-11 ($10.25) Ages 12-54 ($15.50) Age 55 or older ($12) If 4 tickets are purchased (not counting under age 3) then 20% discount Within the loop: Keep asking the user to input the moviegoer age and to enter a zero for the age when they are finished inputting all the family members. Also, within the loop: Keep a running_total that is output to the screenafter each age has been entered. This running_total should be accessed through the functions using apass-by-reference variable. Finally, after the looping is done: Calculate the total cost, including a 7.5% sales tax, and output it to the screen.arrow_forward
- Which of the following arithmetic operations may be performed on struct variables but not on array variables?arrow_forward1. An iron manufacturing company maintains data about all of its employees, including every employee’s name, unique ID, age, native city, contact number, the department to which she or he belongs, and gross salary. The company wants a program that can sort the employees based on their native city in order to easily trace how many employees belong to the same region. Write a program module by using ‘strcmp’ to sort all the available names of cities in an ascending order. IN C PROGRAMMING LANGUAGE AND DON’T COPY AND PASTE THE ONE HERE IN BARTELBY BECAUSE ITS DONE IN C++ AND DOESN’T SOLVE THE PROBLEM RIGHTarrow_forwardWhich of the following C# types cannot contain floating-point numbers? a. float b. double c. decimal d. intarrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning