Integer division refers to dividing two integers where the result is also an integer. In C, when performing integer division, the fractional part (or remainder) is discarded, and only the quotient (the integer part) is kept. This means that if you divide two integers, the result is an integer and any remainder is ignored.
/) and the modulus operator (%).#include <stdio.h>
int main() {
int a = 10;
int b = 3;
int quotient = a / b; // Integer division
int remainder = a % b; // Modulus to get remainder
printf("Quotient: %d, Remainder: %d\n", quotient, remainder);
return 0;
}
In this example:
a / b calculates the quotient, which is 3 (since 10 divided by 3 is 3.333... and the fractional part is discarded).a % b calculates the remainder, which is 1 (since 10 divided by 3 leaves a remainder of 1).So, the output would be:
Quotient: 3, Remainder: 1
-10 / 3 would result in -3, not -4 (the result is rounded towards zero).float or double.Example with floating-point division:
#include <stdio.h>
int main() {
int a = 10;
int b = 3;
float result = (float)a / b; // Casting to float for decimal result
printf("Result: %.2f\n", result); // Output: Result: 3.33
return 0;
}
A flowchart is a graphical representation of a process or algorithm. It helps visualize the steps and decisions in a program or system. Flowcharts are widely used in problem-solving, programming, and software design because they provide a clear, step-by-step approach to solving a problem.
Oval (Terminal)
The oval shape is used to indicate the start and end of a flowchart. It marks the entry and exit points in a process.
+------------------+
| Start |
+------------------+
Rectangle (Process)
The rectangle is used to represent a process or operation. It is used to show actions like assignments, calculations, or other operations.
+--------------------+
| x = x + 1 |
+--------------------+
Parallelogram (Input/Output)
The parallelogram shape represents input or output operations. It is used when data is either being received from the user or displayed to the user.
+----------------------+
| Read x |
+----------------------+
Diamond (Decision)
The diamond shape is used to represent a decision or a branching point in the process. It indicates a point where a decision must be made (usually a condition or comparison).
if or while statement.+----------------------+
| x > 5? |
+----------------------+
Arrow (Flowline)
The arrow represents the flow of control in the flowchart. It connects the different symbols and shows the direction in which the process flows.
----> (indicating the flow)
Here is an example of a simple flowchart to calculate the sum of two numbers:
a and b.a and b, store the result in sum.sum. +------------------+
| Start |
+------------------+
|
v
+------------------+
| Input a, b |
+------------------+
|
v
+------------------+
| sum = a + b |
+------------------+
|
v
+------------------+
| Output sum |
+------------------+
|
v
+------------------+
| End |
+------------------+
a and b using the parallelogram shape.sum = a + b) inside the rectangle.sum) using another parallelogram.%. The result is always an integer.Open this section to load past papers