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++: Early Objects (10th Edition)
- What's the difference between a float and a double integer, exactly?arrow_forwardWhat are the memory sections for variables in the following code: int *x=new int; static int y; int z;arrow_forwardWhich of the following arithmetic operations may be performed on struct variables but not on array variables?arrow_forward
- Is the following an example of integer division or floating-point division? Whatvalue will be stored in portion ?portion = 70 / 3;arrow_forwardPlease show me how to typecast a float variable to integer explicit with the help of a program in C++. Take the float value as 10.998.arrow_forwardConsider the following C++ code and answer the questions: const int size=5; int Num[size]; for (int i = 0; i < size; i++) Num [i] = i * i + 1; a) What is the value of *Num? b) What is the value of *Num+1? c) What is the value of *(Num+2)?arrow_forward
- Which is correct with respect to the size of the data types? a) char > int < float b) int < char > float c) char < int < float d) char < int < doublearrow_forwardPlease show me how to typecast a float variable to integer explicit with the help of a program in C++. Take the float value as float f= 12.91arrow_forwardGiven sphereRadius, compute the volume of a sphere and assign sphereVolume with the result. Use (4.0 / 3.0) to perform floating-point division, instead of (4 / 3) which performs integer division.Volume of sphere = (4.0 / 3.0) π r3 (Hint: r3 can be computed using *. Use the constant M_PI for the value of pi.) #include <stdio.h>#include <math.h> int main(void) { double sphereVolume; double sphereRadius; scanf("%lf", &sphereRadius); /* Your solution goes here */ printf("%.2lf\n", sphereVolume); return 0;arrow_forward
- Which of the following C# types cannot contain floating-point numbers? a. float b. double c. decimal d. intarrow_forwardThe language we are using here is in Racket. Please enter the following code: (cond ((equal? 16 3) (+ 3 8)) ((equal? 16 8) 12) (else (* 6 3))) Write the return value for the above code. If replacing all of the 16's in the above code with 8, what is the return value? What about replacing the 16’s with 3? What does the cond function do?arrow_forward30 Suppose a, b, and sum are int variables and c is a double variable. What value is assigned to each variable after each statement executes? Suppose a = 6, b = 3, and c = 2.2. (14) a b c sum sum = static_cast<int>(a + b + c); __ __ __ __ b += c * a; __ __ __ __ c -= a; __ __ __ __ a *= 2 * b - c; __ __ __ __arrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning