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 (9th Edition)
- explain each code line. all the details.arrow_forwardYour C++ code has the following statement Your C++ code has the following statement Float f=1.25; Please write following the method we discussed in class binary single precision floating point representation of f.arrow_forwardThe following variables have been initialized for you: int a; float f; double d; You have to cast the variable into different data types as follows: Cast a as float to a variable x. Cast f as an integer to a variable y. Cast d as float to a variable z. Hint: You have to initialize the variables x,y and z of proper data typesarrow_forward
- please solve the question new solution, don't copy other solutions in questions bank c++ In this task, you are required to write a code that converts an Octal number into its equivalent Decimal value or vice versa. The user first selects the conversion choice by inserting 1 or 2. Choice 1 is followed by inserting an Octal integer and getting its Decimal equivalent value as an output. Choice 2 requires inserting a Decimal integer and prints out its Octal equivalent. The Octal numeral system, is the base-8 number system, and uses the digits 0 to 7, that is to say 10 octal represents 8 Decimal and 100 octal represents 64 Decimal. Convertion from an Octal integer into Decimal In the Decimal system, each number is the digit multiplied by 10 to the power of its location (starting from 0). For example: 74 decimal = 7 x 10^1 + 4 x 10^0 1252 decimal = 1 x 10^3 + 2 x 10^2 + 5 x 10^1 + 2 x 10^0 each number is the digit multiplied by 8 to the power of its location (starting from 0).…arrow_forwardCreate a program in C language that calculates the month's day from a given year and year's day. Use pointers for the month and month's day variables. Don't forget to add proper errors handling in your program. Example or errors - Invalid Input- Invalid year- Invalid year day Example of input # ./month_day <year> <yearday> # Example for Feb 2nd, 2019:\$ ./month-day 2019 33Feb 02, 2019 I have this class - month-day.c - #include <stdio.h> /* month_day function's prototype*/void month_day(int year, int yearday, int *pmonth, int *pday); int main() {return 0;} Note: I don't need the calendar, please read the instructions well!!arrow_forward2. Test Scores File: test_scores.py Write pseudocode for the main() part of a program that asks the user to enter 4 test scores between 0 and 100, then displays a JCU grade for each score and also the average test score. When you have written the pseudocode for main, implement your solution in Python code and test it with a range of meaningful data. Remember that we've done the JCU grades question before, so copy your function from that practical code file. Sample Output Score: 3 Score: 50.5 Score: 66 Score: 100 Score 3.0, which is N Score 50.5, which is P Score 66.0, which is C Score 100.0, which is HD The average score was 54.875 Enhancements When you have that working... We asked for 4 scores. Have a look at your code... did you use 4 as a numeric literal or a constant?Change 4 to 3... Did you have to change the program in more than one place?If so, then you've missed one of the things we've taught...As a strong guideline: if you need to use the same literal more than once, you…arrow_forward
- function avg and pass x and y Tin printf ("the avg of x and y is %d\n', avgl) give_sqrt (avgl); return 0, float avg (float m, float n) I/ Return the average of n and m void give sqrt (float x) printf ('the sqrt of is Mn'x :/ Print the sqrt value of x. return;arrow_forwardThank you soo much!arrow_forwardQuestion 2 A number in base 2 (binary) is a number such that each of its digits is O or 1. To convert from binary to decimal (base 10), the digits starting from the right are multiplied by powers of 2 (starting at 0) and added. For example, the value in decimal of 10011 is calculated as follows: Write a program that reads from the user a 5-digit integer representing a value in binary and displays its equivalent value in decimal. Note that if the user enters an integer which digits are other than 0 or 1, the program displays a message stating that the number is invalid. Sample Run 1: Enter a 5-digit integer made of Os and 1s: 10011 10011 in decimal is 19 Sample Run 2: Enter a 5-digit integer made of Os and ls: 13001 13001 is not validarrow_forward
- In Java:arrow_forwardhexadecimalWe usually write numbers in decimal form (or base 10),meaning numbers arecomposed using 10 different “digits” f0; 1; : : : ; 9g.Sometimes though it is useful to write numbers hexadecimal or base16. Now there are 16 distinct digits that can be used to form numbers:f0; 1; : : : ; 9;A; B; C;D; E; Fg. So for example, a 3 digit hexadecimalnumber might be 2B8.(a) How many 2-digit hexadecimals are there in which the first digitis E or F? Explain your answer in terms of the additive principle(using either events or sets).(b) Explain why your answer to the previous part is correct in termsof the multiplicative principle (using either events or sets). Whydo both the additive and multiplicative principles give you thesame answer?(c) How many 3-digit hexadecimals start with a letter (A-F) and endwith a numeral (0-9)? Explain.(d) How many 3-digit hexadecimals start with a letter (A-F) or endwith a numeral (0-9) (or both)? Explain.arrow_forwardc++ programarrow_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