KEMBAR78
C Programming Lab - Session 1 - Flowcharts for Programs | PDF
Dr. Rohan Dasgupta
C Programming Lab
VSEC102
What is
programming?
Programming
Codes are written using
programming languages
and are designed to
solve specific problems,
automate tasks,
create applications etc.
Programming is the
process of writing
instructions,
known as code,
for a computer to execute.
Programming Language
Codes are written using
programming languages
and are designed to
solve specific problems,
automate tasks,
create applications etc.
Programming language
is a formal language
used to communicate
instructions to
a computer.
Programming Language
Programming languages
are used to
implement algorithms,
create software,
manipulate data, and
control hardware.
It consists of
a set of syntax rules
and vocabulary
for writing software.
Types of Programming Languages
● Compiled & interpreted
● Concurrent/parallel
● Declarative languages
● Event driven languages
● Visual
● Low level
● High level
● System
● Domain specific
● Markup
Low Level Programming Languages
● Abstraction: minimum (close to hardware)
● Machine dependence: dependent (instructions are specific to
the hardware architecture)
● Examples: machine language, assembly language
● Syntax: uses binary (machine language) or mnemonics
(assembly)
● Execution speed: very fast (as it operates directly on hardware)
Low Level Programming Languages
● Memory Management: manual
● Ease of Learning: difficult (to learn and write)
● Control over hardware: high (allow precise control of hardware)
● Portability: low (platform specific)
● Development time: slower (programming is detailed & complex)
● Use cases: system-level programming (e.g., operating systems,
embedded systems).
High Level Programming Languages
● Abstraction: high (focusing on ease of use)
● Machine dependence: independent (can run on different
architectures with minimum modifications)
● Examples: Python, Java, C++, Ruby, JavaScript etc.
● Syntax: uses more human-readable code (e.g. if, else).
● Execution speed: slower (due to abstraction layer)
High Level Programming Languages
● Memory Management: automatic
● Ease of Learning: easier (to learn, write and understand)
● Control over hardware: low (abstracts away hardware-specific
details)
● Portability: high (not platform specific)
● Development time: faster (simple syntax, available libraries)
● Use cases: app development, scientific computing etc.
Characteristics of C programming
● Abstraction: high
● Machine dependence: somewhat independent
● Syntax: uses more human-readable code (e.g. if, else)
● Portability: moderate
● Ease of Learning: easier (to learn, write and understand)
● Memory Management: manual
● Control over hardware: high (allow precise control of hardware)
What type of programming language
is C?
a) Low level
b) High level
What type of programming language
is C?
a) Low level
b) High level
c) Medium level
Flowcharts
for Programs
Algorithm
● a step-by-step set of instructions or rules designed to
solve a problem or perform a specific task
● usually used in computer programming and
mathematics
Features of Algorithm
● Input: data that the algorithm needs to process
● Output: result produced by the algorithm
● Steps: detailed sequence of actions that lead from input to output.
● Conditions: logical conditions for the algorithm’s decision making
● Control Structures: loops & conditional statements that control the
flow of the algorithm
● Termination: the point at which the algorithm stops
Example of Algorithm
● A simple algorithm to find the largest number in a list
- Start with the first element in the list.
- Compare it with the next element.
- If the next element is larger, remember it as the largest.
- Repeat until you reach the end of the list.
- Return the largest number.
Flowchart
● Flowchart is a graphical representation of an algorithm
● Programmers often use it as a program-planning tool to
solve a problem
● It makes use of symbols which are connected among
them to indicate the flow of information and processing
Symbols used in Flowchart
Terminal: The oval symbol indicates Start, Stop and Halt in a
program’s logic flow. A pause/halt is generally used in a
program logic under some error conditions. Terminal is the
first and last symbols in the flowchart.
Symbols used in Flowchart
Input/Output: A parallelogram denotes any function of
input/output type. Program instructions that take input from
input devices and display output on output devices are
indicated with parallelogram in a flowchart.
Symbols used in Flowchart
Processing: A box represents arithmetic instructions. All
arithmetic processes such as adding, subtracting,
multiplication and division are indicated by action or process
symbol.
Symbols used in Flowchart
Decision: Diamond symbol represents a decision point.
Decision based operations such as yes/no question or
true/false are indicated by diamond in flowchart.
Symbols used in Flowchart
Connectors: Whenever flowchart becomes complex or it
spreads over more than one page, it is useful to use
connectors to avoid any confusions. It is represented by a
circle.
Symbols used in Flowchart
Flow lines: Flow lines indicate the exact sequence in which
instructions are executed. Arrows represent the direction of
flow of control and relationship among different symbols of
flowchart.
Rules for creating Flowchart
Rule 1: Flowchart opening statement must be ‘start’ keyword.
Rule 2: Flowchart ending statement must be ‘end’ keyword.
Rule 3: All symbols in the flowchart must be connected with
an arrow line.
Rule 4: The decision symbol in the flowchart is associated
with the arrow line.
Example of Flowchart
Start
Input
num1
num1 >
num2
Input
num2
num2
num1
True
False
Stop
Advantages of Flowchart
● Flowcharts are a better way of communicating the logic of the system.
● Flowcharts act as a guide for blueprint during program designed.
● Flowcharts help in debugging process.
● With the help of flowcharts programs can be easily analyzed.
● It provides better documentation.
● Flowcharts serve as a good proper documentation.
● Easy to trace errors in the software.
● Easy to understand.
● The flowchart can be reused for inconvenience in the future.
● It helps to provide correct logic.
Disadvantages of Flowchart
● It is difficult to draw flowcharts for large and complex programs.
● There is no standard to determine the amount of detail.
● Difficult to reproduce the flowcharts.
● It is very difficult to modify the Flowchart.
● Making a flowchart is costly.
● Some developer thinks that it is waste of time.
● It makes software processes low.
● If changes are done in software, then the flowchart must be redrawn
1. What is an algorithm? What are its features? Give an example
for an algorithm.
2. What is a flowchart? What are the rules of flowchart?
3. What are the symbols used in flowchart? Give an example for a
flowchart.
4. What are the advantages of flowchart?
5. What are the disadvantages of flowchart?
Rubrics:
1. Timely submission: 4 marks (next week), 2 marks (week after)
2. Correct answers: 1 mark per question
3. Neatness: 1 mark
Assignment No. 1
Flowcharts for Programs
Thank you.
Dr. Rohan Dasgupta
C Programming Lab - Session 1 - Flowcharts for Programs

C Programming Lab - Session 1 - Flowcharts for Programs

  • 1.
    Dr. Rohan Dasgupta CProgramming Lab VSEC102
  • 2.
  • 3.
    Programming Codes are writtenusing programming languages and are designed to solve specific problems, automate tasks, create applications etc. Programming is the process of writing instructions, known as code, for a computer to execute.
  • 4.
    Programming Language Codes arewritten using programming languages and are designed to solve specific problems, automate tasks, create applications etc. Programming language is a formal language used to communicate instructions to a computer.
  • 5.
    Programming Language Programming languages areused to implement algorithms, create software, manipulate data, and control hardware. It consists of a set of syntax rules and vocabulary for writing software.
  • 6.
    Types of ProgrammingLanguages ● Compiled & interpreted ● Concurrent/parallel ● Declarative languages ● Event driven languages ● Visual ● Low level ● High level ● System ● Domain specific ● Markup
  • 7.
    Low Level ProgrammingLanguages ● Abstraction: minimum (close to hardware) ● Machine dependence: dependent (instructions are specific to the hardware architecture) ● Examples: machine language, assembly language ● Syntax: uses binary (machine language) or mnemonics (assembly) ● Execution speed: very fast (as it operates directly on hardware)
  • 8.
    Low Level ProgrammingLanguages ● Memory Management: manual ● Ease of Learning: difficult (to learn and write) ● Control over hardware: high (allow precise control of hardware) ● Portability: low (platform specific) ● Development time: slower (programming is detailed & complex) ● Use cases: system-level programming (e.g., operating systems, embedded systems).
  • 9.
    High Level ProgrammingLanguages ● Abstraction: high (focusing on ease of use) ● Machine dependence: independent (can run on different architectures with minimum modifications) ● Examples: Python, Java, C++, Ruby, JavaScript etc. ● Syntax: uses more human-readable code (e.g. if, else). ● Execution speed: slower (due to abstraction layer)
  • 10.
    High Level ProgrammingLanguages ● Memory Management: automatic ● Ease of Learning: easier (to learn, write and understand) ● Control over hardware: low (abstracts away hardware-specific details) ● Portability: high (not platform specific) ● Development time: faster (simple syntax, available libraries) ● Use cases: app development, scientific computing etc.
  • 11.
    Characteristics of Cprogramming ● Abstraction: high ● Machine dependence: somewhat independent ● Syntax: uses more human-readable code (e.g. if, else) ● Portability: moderate ● Ease of Learning: easier (to learn, write and understand) ● Memory Management: manual ● Control over hardware: high (allow precise control of hardware)
  • 12.
    What type ofprogramming language is C? a) Low level b) High level
  • 13.
    What type ofprogramming language is C? a) Low level b) High level c) Medium level
  • 18.
  • 19.
    Algorithm ● a step-by-stepset of instructions or rules designed to solve a problem or perform a specific task ● usually used in computer programming and mathematics
  • 20.
    Features of Algorithm ●Input: data that the algorithm needs to process ● Output: result produced by the algorithm ● Steps: detailed sequence of actions that lead from input to output. ● Conditions: logical conditions for the algorithm’s decision making ● Control Structures: loops & conditional statements that control the flow of the algorithm ● Termination: the point at which the algorithm stops
  • 21.
    Example of Algorithm ●A simple algorithm to find the largest number in a list - Start with the first element in the list. - Compare it with the next element. - If the next element is larger, remember it as the largest. - Repeat until you reach the end of the list. - Return the largest number.
  • 22.
    Flowchart ● Flowchart isa graphical representation of an algorithm ● Programmers often use it as a program-planning tool to solve a problem ● It makes use of symbols which are connected among them to indicate the flow of information and processing
  • 23.
    Symbols used inFlowchart Terminal: The oval symbol indicates Start, Stop and Halt in a program’s logic flow. A pause/halt is generally used in a program logic under some error conditions. Terminal is the first and last symbols in the flowchart.
  • 24.
    Symbols used inFlowchart Input/Output: A parallelogram denotes any function of input/output type. Program instructions that take input from input devices and display output on output devices are indicated with parallelogram in a flowchart.
  • 25.
    Symbols used inFlowchart Processing: A box represents arithmetic instructions. All arithmetic processes such as adding, subtracting, multiplication and division are indicated by action or process symbol.
  • 26.
    Symbols used inFlowchart Decision: Diamond symbol represents a decision point. Decision based operations such as yes/no question or true/false are indicated by diamond in flowchart.
  • 27.
    Symbols used inFlowchart Connectors: Whenever flowchart becomes complex or it spreads over more than one page, it is useful to use connectors to avoid any confusions. It is represented by a circle.
  • 28.
    Symbols used inFlowchart Flow lines: Flow lines indicate the exact sequence in which instructions are executed. Arrows represent the direction of flow of control and relationship among different symbols of flowchart.
  • 29.
    Rules for creatingFlowchart Rule 1: Flowchart opening statement must be ‘start’ keyword. Rule 2: Flowchart ending statement must be ‘end’ keyword. Rule 3: All symbols in the flowchart must be connected with an arrow line. Rule 4: The decision symbol in the flowchart is associated with the arrow line.
  • 30.
    Example of Flowchart Start Input num1 num1> num2 Input num2 num2 num1 True False Stop
  • 31.
    Advantages of Flowchart ●Flowcharts are a better way of communicating the logic of the system. ● Flowcharts act as a guide for blueprint during program designed. ● Flowcharts help in debugging process. ● With the help of flowcharts programs can be easily analyzed. ● It provides better documentation. ● Flowcharts serve as a good proper documentation. ● Easy to trace errors in the software. ● Easy to understand. ● The flowchart can be reused for inconvenience in the future. ● It helps to provide correct logic.
  • 32.
    Disadvantages of Flowchart ●It is difficult to draw flowcharts for large and complex programs. ● There is no standard to determine the amount of detail. ● Difficult to reproduce the flowcharts. ● It is very difficult to modify the Flowchart. ● Making a flowchart is costly. ● Some developer thinks that it is waste of time. ● It makes software processes low. ● If changes are done in software, then the flowchart must be redrawn
  • 33.
    1. What isan algorithm? What are its features? Give an example for an algorithm. 2. What is a flowchart? What are the rules of flowchart? 3. What are the symbols used in flowchart? Give an example for a flowchart. 4. What are the advantages of flowchart? 5. What are the disadvantages of flowchart? Rubrics: 1. Timely submission: 4 marks (next week), 2 marks (week after) 2. Correct answers: 1 mark per question 3. Neatness: 1 mark Assignment No. 1 Flowcharts for Programs
  • 34.