ScholarQuill logoScholarQuillUniversity Notes
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
Study Tools
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
Contact
ScholarQuill logo
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
ScholarQuill logoScholarQuillUniversity Notes
Study PortalCC-112Integer Division Flowc…
Ctrl + K
Login
Explore
Search
Semester
Papers
CGPA
    CC-112

    Programming Fundamentals

    Progress0 / 39 done
    Topics39
    1Introduction to Problem Solving, Algorithms, Programming, and C Language2Problem Solving, a brief review of Von-Neumann Architecture3The C Programming Language, Pseudo-code, Concept of Variable4Data types in Pseudo-code, The C Standard Library and Open Source5Input/Output, Arithmetic expressions, Assignment statement, Operator precedence6Concept of Integer division, Flowchart and its notations7Typical C Program Development Environment, Role of Compiler and Linker8Test Driving C Application
    9A Simple C Program: Printing Text, Adding Two Integer10Memory Concepts, Arithmetic in C, Operators
    11Equality and Relational Operators
    12The if, if...else, while Nested Control Statements
    13for, switch, do...while, break, continue, Logical Operators
    14Modularizing Program in C, Math Library Functions15Function Definitions and Prototypes, Function-Call Stack and Stack Frames16Stack rolling and unrolling, Headers, Passing Arguments by Value and by Reference17Random Number Generation, Scope Rules, Recursion, Recursion vs Iteration
    18Defining Arrays, Character Arrays, Static and Automatic Local Arrays19Passing Arrays to Function, Sorting and Searching Arrays20Multidimensional and Variable Length Arrays
    21Pointer Definitions and Initialization, Pointer Operators22Passing Arguments to Function by Reference, Using the const and sizeof Operator23Pointer Expressions and Arithmetic, Pointers and Arrays, Array of Pointers24Function Pointers
    25Strings and Characters, Character Handling Library26String Functions, Library Functions
    27Streams, Formatted Output with printf, Formatted Input with scanf
    28Defining Structures, Accessing Structure Member, Structures and Functions29typedef, Unions
    30Bitwise Operators, Bit Fields, Enumeration Constants
    31Files and Streams, Creating, Reading and Writing data to a Sequential and a Random-Access File
    32#include, #define, Conditional Compilation, #error and #pragma33# and ## Operators, Predefined Symbolic Constants, Assertions
    34Variable Length Argument List, Using Command Line Arguments35Compiling Multiple-Source-File Programs, Program Termination with exit and atexit36Suffixes for Integer and Floating-Point Literals, Signal Handling
    37calloc and realloc, goto
    38Self-Referential Structures, Linked Lists39Efficiency of Algorithms, Selection and Insertion Sort
    5 min read
    Topic 6 of 39
    Topic Study Note Illustration
    06

    Concept of Integer division, Flowchart and its notations

    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,...

    Concept of Integer Division in C

    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.

    How Integer Division Works in C

    • When both operands are integers, the division operation results in an integer, and any remainder is discarded.
    • If you want to get the quotient and remainder, you can use both the division operator (/) and the modulus operator (%).

    Example of Integer Division

    #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
    

    Important Notes on Integer Division

    • Negative Results: When dividing two integers where one or both are negative, C truncates the result towards zero. For example, -10 / 3 would result in -3, not -4 (the result is rounded towards zero).
    • Casting: If you want to obtain a floating-point result from the division of integers, you can cast one or both operands to 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;
    }
    

    Flowchart and Its Notations

    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.

    Basic Flowchart Symbols and Notations

    1. 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 and End are represented by ovals.
      • Notation: An oval with the words "Start" or "End" inside.
      • Example:
        +------------------+
        |      Start       |
        +------------------+
        
    2. Rectangle (Process)
      The rectangle is used to represent a process or operation. It is used to show actions like assignments, calculations, or other operations.

      • Example: A process step where a variable is assigned a value or an arithmetic operation is performed.
      • Notation: A rectangle with the operation or action inside.
        +--------------------+
        |   x = x + 1        |
        +--------------------+
        
    3. 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.

      • Example: Reading input or printing output.
      • Notation: A parallelogram with input or output operation inside.
        +----------------------+
        |   Read x             |
        +----------------------+
        
    4. 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).

      • Example: A decision such as if or while statement.
      • Notation: A diamond with the condition or decision inside.
        +----------------------+
        | x > 5?               |
        +----------------------+
        
    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.

      • Example: An arrow pointing from one step to the next.
      • Notation: A simple arrow connecting the shapes.
        ---->  (indicating the flow)
        

    Example Flowchart

    Here is an example of a simple flowchart to calculate the sum of two numbers:

    1. Start
    2. Input: Read two numbers, a and b.
    3. Process: Add a and b, store the result in sum.
    4. Output: Print sum.
    5. End

    Flowchart Representation:

              +------------------+
              |      Start       |
              +------------------+
                      |
                      v
              +------------------+
              |  Input a, b      |
              +------------------+
                      |
                      v
              +------------------+
              |  sum = a + b     |
              +------------------+
                      |
                      v
              +------------------+
              |  Output sum      |
              +------------------+
                      |
                      v
              +------------------+
              |      End         |
              +------------------+
    

    Steps to Read the Flowchart:

    1. Start at the "Start" oval.
    2. Read the input values for a and b using the parallelogram shape.
    3. Perform the addition (sum = a + b) inside the rectangle.
    4. Output the result (sum) using another parallelogram.
    5. End the process in the "End" oval.

    Summary

    • Integer Division in C discards the fractional part of the division result, and the remainder can be obtained using the modulus operator %. The result is always an integer.
    • A Flowchart is a visual representation of an algorithm or process, helping to map out steps in a logical sequence. Key flowchart symbols include ovals (Start/End), rectangles (Process), parallelograms (Input/Output), diamonds (Decision), and arrows (Flowlines).
    • Flowcharts are helpful in designing algorithms, ensuring clarity in program structure, and aiding in problem-solving.
    ← Previous topic 5
    Input/Output, Arithmetic expressions, Assignment statement, Operator precedence
    Next topic 7 →
    Typical C Program Development Environment, Role of Compiler and Linker

    Past Papers

    Open this section to view and download past papers

    Click on Show Past Papers to load available exam papers.

    Reading Progress
    0%
    5mremaining
    876words
    Beginnerlevel
    On This Page

    No headings found

    Study Toolkit

    Subject Portal

    Programming Fundamentals