SlideShare a Scribd company logo
Structured
Programming
Language
ALGORITHM, PSEUDO CODE, FLOW CHART,
COMPILATION PROCESS
Mohammad Imam Hossain
Lecturer, CSE, UIU
Algorithm
• Complete step by step representation of the solution of the
problem, represented in English like language.
Pseudo
Code
• More formal representation than the algorithm
• Very close to actual programming language
Flow chart
• Uses many graphical symbols to represent the steps of the
solution of the problem.
Program
• A set of instructions
• Written in a particular sequence in a computer-related language
Problem:Write a program to find the average of n numbers.
Algorithm:
1. Read the value of n
2. Read n numbers
3. Add these n numbers
4. Divide the addition
result by n to get the
average
5. Print the average
Pseudo Code:
1. Start
2. Read n
3. sum  0
4. for i  1 to n do
5. read i-th number
6. sum  sum + i-th number
7. end for
8. average  sum/n
9. print average
10. stop
Flow Chart
• Graphical Symbols
Start, Stop
Read, Print
Processing statements
Conditional check
Direction of flow
Connectors
Problem:Write a program to find
the average of n numbers.
Flow Chart >>
start
Read n
sum  0
i  1
i<= n
?
Read numberi
sum  sum + numberi
ii+1
average  sum/n
Print average
stop
n=3 and the numbers are: 10,20,30
yes
no
Problem:Write a program to find
the average of n numbers.
Flow Chart >>
start
Read n
sum  0
i  1
i<= n
?
Read numberi
sum  sum + numberi
ii+1
average  sum/n
Print average
stop
n=3 and the numbers are: 10,20,30
yes
no
Problem:Write a program to find
the average of n numbers.
Flow Chart >>
start
Read n
sum  0
i  1
i<= n
?
Read numberi
sum  sum + numberi
ii+1
average  sum/n
Print average
stop
n=3 and the numbers are: 10,20,30
yes
no
Problem:Write a program to find
the average of n numbers.
Flow Chart >>
start
Read n
sum  0
i  1
i<= n
?
Read numberi
sum  sum + numberi
ii+1
average  sum/n
Print average
stop
n=3 and the numbers are: 10,20,30
yes
no
Problem:Write a program to find
the average of n numbers.
Flow Chart >>
start
Read n
sum  0
i  1
i<= n
?
Read numberi
sum  sum + numberi
ii+1
average  sum/n
Print average
stop
n=3 and the numbers are: 10,20,30
yes
no
Problem:Write a program to find
the average of n numbers.
Flow Chart >>
start
Read n
sum  0
i  1
i<= n
?
Read numberi
sum  sum + numberi
ii+1
average  sum/n
Print average
stop
n=3 and the numbers are: 10,20,30
yes
no
Problem:Write a program to find
the average of n numbers.
Flow Chart >>
start
Read n
sum  0
i  1
i<= n
?
Read numberi
sum  sum + numberi
ii+1
average  sum/n
Print average
stop
n=3 and the numbers are: 10,20,30
sum=0+10=10, i=2
yes
no
Problem:Write a program to find
the average of n numbers.
Flow Chart >>
start
Read n
sum  0
i  1
i<= n
?
Read numberi
sum  sum + numberi
ii+1
average  sum/n
Print average
stop
n=3 and the numbers are: 10,20,30
sum=0+10=10, i=2
yes
no
Problem:Write a program to find
the average of n numbers.
Flow Chart >>
start
Read n
sum  0
i  1
i<= n
?
Read numberi
sum  sum + numberi
ii+1
average  sum/n
Print average
stop
n=3 and the numbers are: 10,20,30
sum=0+10=10, i=2
yes
no
Problem:Write a program to find
the average of n numbers.
Flow Chart >>
start
Read n
sum  0
i  1
i<= n
?
Read numberi
sum  sum + numberi
ii+1
average  sum/n
Print average
stop
n=3 and the numbers are: 10,20,30
sum=0+10=10, i=2
sum=10+20=30, i=3
yes
no
Problem:Write a program to find
the average of n numbers.
Flow Chart >>
start
Read n
sum  0
i  1
i<= n
?
Read numberi
sum  sum + numberi
ii+1
average  sum/n
Print average
stop
n=3 and the numbers are: 10,20,30
sum=0+10=10, i=2
sum=10+20=30, i=3
yes
no
Problem:Write a program to find
the average of n numbers.
Flow Chart >>
start
Read n
sum  0
i  1
i<= n
?
Read numberi
sum  sum + numberi
ii+1
average  sum/n
Print average
stop
n=3 and the numbers are: 10,20,30
sum=0+10=10, i=2
sum=10+20=30, i=3
yes
no
Problem:Write a program to find
the average of n numbers.
Flow Chart >>
start
Read n
sum  0
i  1
i<= n
?
Read numberi
sum  sum + numberi
ii+1
average  sum/n
Print average
stop
n=3 and the numbers are: 10,20,30
sum=0+10=10, i=2
sum=10+20=30, i=3
sum=30+30=60, i=4
yes
no
Problem:Write a program to find
the average of n numbers.
Flow Chart >>
start
Read n
sum  0
i  1
i<= n
?
Read numberi
sum  sum + numberi
ii+1
average  sum/n
Print average
stop
n=3 and the numbers are: 10,20,30
sum=0+10=10, i=2
sum=10+20=30, i=3
sum=30+30=60, i=4
yes
no
Problem:Write a program to find
the average of n numbers.
Flow Chart >>
start
Read n
sum  0
i  1
i<= n
?
Read numberi
sum  sum + numberi
ii+1
average  sum/n
Print average
stop
n=3 and the numbers are: 10,20,30
sum=0+10=10, i=2
sum=10+20=30, i=3
sum=30+30=60, i=4
average=60/3=20
yes
no
Problem:Write a program to find
the average of n numbers.
Flow Chart >>
start
Read n
sum  0
i  1
i<= n
?
Read numberi
sum  sum + numberi
ii+1
average  sum/n
Print average
stop
n=3 and the numbers are: 10,20,30
sum=0+10=10, i=2
sum=10+20=30, i=3
sum=30+30=60, i=4
average=60/3=20
yes
no
Problem:Write a program to find
the average of n numbers.
Flow Chart >>
start
Read n
sum  0
i  1
i<= n
?
Read numberi
sum  sum + numberi
ii+1
average  sum/n
Print average
stop
n=3 and the numbers are: 10,20,30
sum=0+10=10, i=2
sum=10+20=30, i=3
sum=30+30=60, i=4
average=60/3=20
yes
no
Practice problems:
1. Draw flow chart to decide whether a number is even or odd.
2. Draw flow chart to find out the sum of the following series:
a) 1+3+5+… … + 99
b) 1+
1
3
+
1
5
+ … … +
1
27
c) 1+1+2+3+5+8+13+… … + upto 100th terms (Fibonacci series)
3. Draw flow chart to find out the factorial of n,
1*2*3*… … *n
4. Draw flow chart to find out the maximum of 3 numbers.
5. Draw flow chart to check whether a number is prime or not.
6. Draw flow chart to find out the gcd of 2 numbers.
GCD Problem:
15 ) 21 ( 1
15
---------------
6 ) 15 ( 2
12
--------------
3 ) 6 ( 2
6
------------
0
GCD Problem:
15 ) 21 ( 1
15
---------------
6 ) 15 ( 2
12
--------------
3 ) 6 ( 2
6
------------
0
a b
check
GCD Problem:
15 ) 21 ( 1
15
---------------
6 ) 15 ( 2
12
--------------
3 ) 6 ( 2
6
------------
0
a b
check
GCD Problem:
15 ) 21 ( 1
15
---------------
6 ) 15 ( 2
12
--------------
3 ) 6 ( 2
6
------------
0
a b
check
GCD Problem:
15 ) 21 ( 1
15
---------------
6 ) 15 ( 2
12
--------------
3 ) 6 ( 2
6
------------
0
a b
check
Start
input a , b
check b % a
check=0
?
ba
a check
print a
stop
No
Yes
check b % a
C Programs Building Process:
C program building process involves four stages. At
the end there should be a single executable file.
1. Preprocessing is the first pass of any C
compilation. It processes include-files, define,
conditional compilation instructions and macros.
Source Code
hello.c
C Preprocessor
C Programs Building Process:
C program building process involves four stages. At
the end there should be a single executable file.
1. Preprocessing is the first pass of any C
compilation. It processes include-files, define,
conditional compilation instructions and macros.
Source Code
hello.c
PreprocessedCode
hello.i
C Preprocessor
C Programs Building Process:
C program building process involves four stages. At
the end there should be a single executable file.
1. Preprocessing is the first pass of any C
compilation. It processes include-files, define,
conditional compilation instructions and macros.
Source Code
hello.c
PreprocessedCode
hello.i
C Preprocessor
C Compiler
2. Compilation is the second pass. It takes the
output of the preprocessor and the source
code and generates assembler source code.
C Programs Building Process:
C program building process involves four stages. At
the end there should be a single executable file.
1. Preprocessing is the first pass of any C
compilation. It processes include-files, define,
conditional compilation instructions and macros.
Source Code
hello.c
PreprocessedCode
hello.i
Assembly code
hello.s
C Preprocessor
C Compiler
2. Compilation is the second pass. It takes the
output of the preprocessor and the source
code and generates assembler source code.
C Programs Building Process:
C program building process involves four stages. At
the end there should be a single executable file.
1. Preprocessing is the first pass of any C
compilation. It processes include-files, define,
conditional compilation instructions and macros.
Source Code
hello.c
PreprocessedCode
hello.i
Assembly code
hello.s
C Preprocessor
C Compiler
Assembler
2. Compilation is the second pass. It takes the
output of the preprocessor and the source
code and generates assembler source code.
3. Assembly is the third stage that takes the
assembly source code and produces an assembly
listing with offsets.The assembler output is stored
in an object file.
C Programs Building Process:
C program building process involves four stages. At
the end there should be a single executable file.
1. Preprocessing is the first pass of any C
compilation. It processes include-files, define,
conditional compilation instructions and macros.
Source Code
hello.c
PreprocessedCode
hello.i
Object code
hello.o
Assembly code
hello.s
C Preprocessor
C Compiler
Assembler
2. Compilation is the second pass. It takes the
output of the preprocessor and the source
code and generates assembler source code.
3. Assembly is the third stage that takes the
assembly source code and produces an assembly
listing with offsets.The assembler output is stored
in an object file.
C Programs Building Process:
C program building process involves four stages. At
the end there should be a single executable file.
1. Preprocessing is the first pass of any C
compilation. It processes include-files, define,
conditional compilation instructions and macros.
Source Code
hello.c
PreprocessedCode
hello.i
Executable code
hello.exe
Object code
hello.o
Assembly code
hello.s
C Preprocessor
C Compiler
Assembler
Linker
2. Compilation is the second pass. It takes the
output of the preprocessor and the source
code and generates assembler source code.
3. Assembly is the third stage that takes the
assembly source code and produces an assembly
listing with offsets.The assembler output is stored
in an object file.
4. Linking is the final stage that takes one or more
object files or libraries as input and combines them to
produce a single (executable) file.
Library Files
Other Object files
Relocation object
code information
Compiling using command prompt:
1. Write your code into a text editor and name the file with .c extention.
2. Add your gcc compiler’s bin directory path into windows environment
variables path variable.
3. Open windows command prompt and write the following command
gcc –c “path of your .c file with file name”
This command will generate the object file with .o extension let,
object_file_name.o
4.Then give the following command
gcc –o exe_file_name object_file_name.o

More Related Content

PPTX
instruction cycle ppt
PPTX
Operating Systems: Device Management
PPTX
Algorithm and pseudo codes
PPTX
Types of Programming Errors
PDF
Introduction to Operating Systems
PPTX
Assembly language
PPTX
Cpu scheduling in operating System.
PDF
OS - Process Concepts
instruction cycle ppt
Operating Systems: Device Management
Algorithm and pseudo codes
Types of Programming Errors
Introduction to Operating Systems
Assembly language
Cpu scheduling in operating System.
OS - Process Concepts

What's hot (20)

PPTX
C and its errors
PPT
PDF
Computer Programming
PPT
Functional units of computer
PPT
Computer Organization and Architecture.
PPTX
Instruction Cycle in Computer Organization.pptx
PPT
Operating system.ppt (1)
PPTX
Paging and segmentation
PPT
Video display devices
PPTX
Peripheral devices
PPTX
Unit 1. Problem Solving with Computer
PPTX
Introduction to computer architecture and organization
PPTX
Process scheduling
PPT
Bios ( Basic Input Output System )
PPTX
Chapter 1 introduction to computers
PDF
Semaphores
PPTX
Data representation in computers
PPTX
Binary computing
PDF
Lecture 01 introduction to compiler
PPTX
Interfacing With High Level Programming Language
C and its errors
Computer Programming
Functional units of computer
Computer Organization and Architecture.
Instruction Cycle in Computer Organization.pptx
Operating system.ppt (1)
Paging and segmentation
Video display devices
Peripheral devices
Unit 1. Problem Solving with Computer
Introduction to computer architecture and organization
Process scheduling
Bios ( Basic Input Output System )
Chapter 1 introduction to computers
Semaphores
Data representation in computers
Binary computing
Lecture 01 introduction to compiler
Interfacing With High Level Programming Language
Ad

Similar to SPL 2 | Algorithms, Pseudo-code, and Flowchart (20)

PDF
Practical 01 (detailed)
PDF
25422733 c-programming-and-data-structures-lab-manual
PDF
Solution of matlab chapter 6
PPTX
Understanding Basic C++ Program for Arithmetic Operations.pptx
DOCX
Cis 170 Extraordinary Success/newtonhelp.com
DOC
CIS 170 Imagine Your Future/newtonhelp.com   
DOC
CIS 170 Life of the Mind/newtonhelp.com   
PDF
Week1 programming challenges
DOCX
CIS 170 Inspiring Innovation/tutorialrank.com
PPTX
Basic pogramming concepts
DOC
CIS 170 Focus Dreams/newtonhelp.com
PDF
CIS 170 Effective Communication - tutorialrank.com
DOCX
COMP 122 Entire Course NEW
PPTX
Lec01-02 (Topic 1 C++ Fundamentals).pptx
PPTX
Flowchart and algorithm
PPT
Programing Fundamental
PPT
Basic of c++ programming
PPT
Cs 1114 - lecture-2
PPTX
CSE115 C Programming Introduction North south university
PPT
Devry cis-170-c-i lab-1-of-7-getting-started
Practical 01 (detailed)
25422733 c-programming-and-data-structures-lab-manual
Solution of matlab chapter 6
Understanding Basic C++ Program for Arithmetic Operations.pptx
Cis 170 Extraordinary Success/newtonhelp.com
CIS 170 Imagine Your Future/newtonhelp.com   
CIS 170 Life of the Mind/newtonhelp.com   
Week1 programming challenges
CIS 170 Inspiring Innovation/tutorialrank.com
Basic pogramming concepts
CIS 170 Focus Dreams/newtonhelp.com
CIS 170 Effective Communication - tutorialrank.com
COMP 122 Entire Course NEW
Lec01-02 (Topic 1 C++ Fundamentals).pptx
Flowchart and algorithm
Programing Fundamental
Basic of c++ programming
Cs 1114 - lecture-2
CSE115 C Programming Introduction North south university
Devry cis-170-c-i lab-1-of-7-getting-started
Ad

More from Mohammad Imam Hossain (20)

PDF
DS & Algo 6 - Offline Assignment 6
PDF
DS & Algo 6 - Dynamic Programming
PDF
DS & Algo 5 - Disjoint Set and MST
PDF
DS & Algo 4 - Graph and Shortest Path Search
PDF
DS & Algo 3 - Offline Assignment 3
PDF
DS & Algo 3 - Divide and Conquer
PDF
DS & Algo 2 - Offline Assignment 2
PDF
DS & Algo 2 - Recursion
PDF
DS & Algo 1 - Offline Assignment 1
PDF
DS & Algo 1 - C++ and STL Introduction
PDF
DBMS 1 | Introduction to DBMS
PDF
DBMS 10 | Database Transactions
PDF
DBMS 3 | ER Diagram to Relational Schema
PDF
DBMS 2 | Entity Relationship Model
PDF
DBMS 7 | Relational Query Language
PDF
DBMS 4 | MySQL - DDL & DML Commands
PDF
DBMS 5 | MySQL Practice List - HR Schema
PDF
TOC 10 | Turing Machine
PDF
TOC 9 | Pushdown Automata
PDF
TOC 8 | Derivation, Parse Tree & Ambiguity Check
DS & Algo 6 - Offline Assignment 6
DS & Algo 6 - Dynamic Programming
DS & Algo 5 - Disjoint Set and MST
DS & Algo 4 - Graph and Shortest Path Search
DS & Algo 3 - Offline Assignment 3
DS & Algo 3 - Divide and Conquer
DS & Algo 2 - Offline Assignment 2
DS & Algo 2 - Recursion
DS & Algo 1 - Offline Assignment 1
DS & Algo 1 - C++ and STL Introduction
DBMS 1 | Introduction to DBMS
DBMS 10 | Database Transactions
DBMS 3 | ER Diagram to Relational Schema
DBMS 2 | Entity Relationship Model
DBMS 7 | Relational Query Language
DBMS 4 | MySQL - DDL & DML Commands
DBMS 5 | MySQL Practice List - HR Schema
TOC 10 | Turing Machine
TOC 9 | Pushdown Automata
TOC 8 | Derivation, Parse Tree & Ambiguity Check

Recently uploaded (20)

PPTX
UNDER FIVE CLINICS OR WELL BABY CLINICS.pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
PPTX
Cell Structure & Organelles in detailed.
PDF
PSYCHOLOGY IN EDUCATION.pdf ( nice pdf ...)
PDF
Insiders guide to clinical Medicine.pdf
PDF
Open folder Downloads.pdf yes yes ges yes
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
English Language Teaching from Post-.pdf
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
UNDER FIVE CLINICS OR WELL BABY CLINICS.pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
O5-L3 Freight Transport Ops (International) V1.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
NOI Hackathon - Summer Edition - GreenThumber.pptx
Cell Structure & Organelles in detailed.
PSYCHOLOGY IN EDUCATION.pdf ( nice pdf ...)
Insiders guide to clinical Medicine.pdf
Open folder Downloads.pdf yes yes ges yes
Renaissance Architecture: A Journey from Faith to Humanism
human mycosis Human fungal infections are called human mycosis..pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
English Language Teaching from Post-.pdf
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Anesthesia in Laparoscopic Surgery in India
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Open Quiz Monsoon Mind Game Final Set.pptx
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
O7-L3 Supply Chain Operations - ICLT Program

SPL 2 | Algorithms, Pseudo-code, and Flowchart

  • 1. Structured Programming Language ALGORITHM, PSEUDO CODE, FLOW CHART, COMPILATION PROCESS Mohammad Imam Hossain Lecturer, CSE, UIU
  • 2. Algorithm • Complete step by step representation of the solution of the problem, represented in English like language. Pseudo Code • More formal representation than the algorithm • Very close to actual programming language Flow chart • Uses many graphical symbols to represent the steps of the solution of the problem. Program • A set of instructions • Written in a particular sequence in a computer-related language
  • 3. Problem:Write a program to find the average of n numbers. Algorithm: 1. Read the value of n 2. Read n numbers 3. Add these n numbers 4. Divide the addition result by n to get the average 5. Print the average Pseudo Code: 1. Start 2. Read n 3. sum  0 4. for i  1 to n do 5. read i-th number 6. sum  sum + i-th number 7. end for 8. average  sum/n 9. print average 10. stop
  • 4. Flow Chart • Graphical Symbols Start, Stop Read, Print Processing statements Conditional check Direction of flow Connectors
  • 5. Problem:Write a program to find the average of n numbers. Flow Chart >> start Read n sum  0 i  1 i<= n ? Read numberi sum  sum + numberi ii+1 average  sum/n Print average stop n=3 and the numbers are: 10,20,30 yes no
  • 6. Problem:Write a program to find the average of n numbers. Flow Chart >> start Read n sum  0 i  1 i<= n ? Read numberi sum  sum + numberi ii+1 average  sum/n Print average stop n=3 and the numbers are: 10,20,30 yes no
  • 7. Problem:Write a program to find the average of n numbers. Flow Chart >> start Read n sum  0 i  1 i<= n ? Read numberi sum  sum + numberi ii+1 average  sum/n Print average stop n=3 and the numbers are: 10,20,30 yes no
  • 8. Problem:Write a program to find the average of n numbers. Flow Chart >> start Read n sum  0 i  1 i<= n ? Read numberi sum  sum + numberi ii+1 average  sum/n Print average stop n=3 and the numbers are: 10,20,30 yes no
  • 9. Problem:Write a program to find the average of n numbers. Flow Chart >> start Read n sum  0 i  1 i<= n ? Read numberi sum  sum + numberi ii+1 average  sum/n Print average stop n=3 and the numbers are: 10,20,30 yes no
  • 10. Problem:Write a program to find the average of n numbers. Flow Chart >> start Read n sum  0 i  1 i<= n ? Read numberi sum  sum + numberi ii+1 average  sum/n Print average stop n=3 and the numbers are: 10,20,30 yes no
  • 11. Problem:Write a program to find the average of n numbers. Flow Chart >> start Read n sum  0 i  1 i<= n ? Read numberi sum  sum + numberi ii+1 average  sum/n Print average stop n=3 and the numbers are: 10,20,30 sum=0+10=10, i=2 yes no
  • 12. Problem:Write a program to find the average of n numbers. Flow Chart >> start Read n sum  0 i  1 i<= n ? Read numberi sum  sum + numberi ii+1 average  sum/n Print average stop n=3 and the numbers are: 10,20,30 sum=0+10=10, i=2 yes no
  • 13. Problem:Write a program to find the average of n numbers. Flow Chart >> start Read n sum  0 i  1 i<= n ? Read numberi sum  sum + numberi ii+1 average  sum/n Print average stop n=3 and the numbers are: 10,20,30 sum=0+10=10, i=2 yes no
  • 14. Problem:Write a program to find the average of n numbers. Flow Chart >> start Read n sum  0 i  1 i<= n ? Read numberi sum  sum + numberi ii+1 average  sum/n Print average stop n=3 and the numbers are: 10,20,30 sum=0+10=10, i=2 sum=10+20=30, i=3 yes no
  • 15. Problem:Write a program to find the average of n numbers. Flow Chart >> start Read n sum  0 i  1 i<= n ? Read numberi sum  sum + numberi ii+1 average  sum/n Print average stop n=3 and the numbers are: 10,20,30 sum=0+10=10, i=2 sum=10+20=30, i=3 yes no
  • 16. Problem:Write a program to find the average of n numbers. Flow Chart >> start Read n sum  0 i  1 i<= n ? Read numberi sum  sum + numberi ii+1 average  sum/n Print average stop n=3 and the numbers are: 10,20,30 sum=0+10=10, i=2 sum=10+20=30, i=3 yes no
  • 17. Problem:Write a program to find the average of n numbers. Flow Chart >> start Read n sum  0 i  1 i<= n ? Read numberi sum  sum + numberi ii+1 average  sum/n Print average stop n=3 and the numbers are: 10,20,30 sum=0+10=10, i=2 sum=10+20=30, i=3 sum=30+30=60, i=4 yes no
  • 18. Problem:Write a program to find the average of n numbers. Flow Chart >> start Read n sum  0 i  1 i<= n ? Read numberi sum  sum + numberi ii+1 average  sum/n Print average stop n=3 and the numbers are: 10,20,30 sum=0+10=10, i=2 sum=10+20=30, i=3 sum=30+30=60, i=4 yes no
  • 19. Problem:Write a program to find the average of n numbers. Flow Chart >> start Read n sum  0 i  1 i<= n ? Read numberi sum  sum + numberi ii+1 average  sum/n Print average stop n=3 and the numbers are: 10,20,30 sum=0+10=10, i=2 sum=10+20=30, i=3 sum=30+30=60, i=4 average=60/3=20 yes no
  • 20. Problem:Write a program to find the average of n numbers. Flow Chart >> start Read n sum  0 i  1 i<= n ? Read numberi sum  sum + numberi ii+1 average  sum/n Print average stop n=3 and the numbers are: 10,20,30 sum=0+10=10, i=2 sum=10+20=30, i=3 sum=30+30=60, i=4 average=60/3=20 yes no
  • 21. Problem:Write a program to find the average of n numbers. Flow Chart >> start Read n sum  0 i  1 i<= n ? Read numberi sum  sum + numberi ii+1 average  sum/n Print average stop n=3 and the numbers are: 10,20,30 sum=0+10=10, i=2 sum=10+20=30, i=3 sum=30+30=60, i=4 average=60/3=20 yes no
  • 22. Practice problems: 1. Draw flow chart to decide whether a number is even or odd. 2. Draw flow chart to find out the sum of the following series: a) 1+3+5+… … + 99 b) 1+ 1 3 + 1 5 + … … + 1 27 c) 1+1+2+3+5+8+13+… … + upto 100th terms (Fibonacci series) 3. Draw flow chart to find out the factorial of n, 1*2*3*… … *n 4. Draw flow chart to find out the maximum of 3 numbers. 5. Draw flow chart to check whether a number is prime or not. 6. Draw flow chart to find out the gcd of 2 numbers.
  • 23. GCD Problem: 15 ) 21 ( 1 15 --------------- 6 ) 15 ( 2 12 -------------- 3 ) 6 ( 2 6 ------------ 0
  • 24. GCD Problem: 15 ) 21 ( 1 15 --------------- 6 ) 15 ( 2 12 -------------- 3 ) 6 ( 2 6 ------------ 0 a b check
  • 25. GCD Problem: 15 ) 21 ( 1 15 --------------- 6 ) 15 ( 2 12 -------------- 3 ) 6 ( 2 6 ------------ 0 a b check
  • 26. GCD Problem: 15 ) 21 ( 1 15 --------------- 6 ) 15 ( 2 12 -------------- 3 ) 6 ( 2 6 ------------ 0 a b check
  • 27. GCD Problem: 15 ) 21 ( 1 15 --------------- 6 ) 15 ( 2 12 -------------- 3 ) 6 ( 2 6 ------------ 0 a b check Start input a , b check b % a check=0 ? ba a check print a stop No Yes check b % a
  • 28. C Programs Building Process: C program building process involves four stages. At the end there should be a single executable file. 1. Preprocessing is the first pass of any C compilation. It processes include-files, define, conditional compilation instructions and macros. Source Code hello.c C Preprocessor
  • 29. C Programs Building Process: C program building process involves four stages. At the end there should be a single executable file. 1. Preprocessing is the first pass of any C compilation. It processes include-files, define, conditional compilation instructions and macros. Source Code hello.c PreprocessedCode hello.i C Preprocessor
  • 30. C Programs Building Process: C program building process involves four stages. At the end there should be a single executable file. 1. Preprocessing is the first pass of any C compilation. It processes include-files, define, conditional compilation instructions and macros. Source Code hello.c PreprocessedCode hello.i C Preprocessor C Compiler 2. Compilation is the second pass. It takes the output of the preprocessor and the source code and generates assembler source code.
  • 31. C Programs Building Process: C program building process involves four stages. At the end there should be a single executable file. 1. Preprocessing is the first pass of any C compilation. It processes include-files, define, conditional compilation instructions and macros. Source Code hello.c PreprocessedCode hello.i Assembly code hello.s C Preprocessor C Compiler 2. Compilation is the second pass. It takes the output of the preprocessor and the source code and generates assembler source code.
  • 32. C Programs Building Process: C program building process involves four stages. At the end there should be a single executable file. 1. Preprocessing is the first pass of any C compilation. It processes include-files, define, conditional compilation instructions and macros. Source Code hello.c PreprocessedCode hello.i Assembly code hello.s C Preprocessor C Compiler Assembler 2. Compilation is the second pass. It takes the output of the preprocessor and the source code and generates assembler source code. 3. Assembly is the third stage that takes the assembly source code and produces an assembly listing with offsets.The assembler output is stored in an object file.
  • 33. C Programs Building Process: C program building process involves four stages. At the end there should be a single executable file. 1. Preprocessing is the first pass of any C compilation. It processes include-files, define, conditional compilation instructions and macros. Source Code hello.c PreprocessedCode hello.i Object code hello.o Assembly code hello.s C Preprocessor C Compiler Assembler 2. Compilation is the second pass. It takes the output of the preprocessor and the source code and generates assembler source code. 3. Assembly is the third stage that takes the assembly source code and produces an assembly listing with offsets.The assembler output is stored in an object file.
  • 34. C Programs Building Process: C program building process involves four stages. At the end there should be a single executable file. 1. Preprocessing is the first pass of any C compilation. It processes include-files, define, conditional compilation instructions and macros. Source Code hello.c PreprocessedCode hello.i Executable code hello.exe Object code hello.o Assembly code hello.s C Preprocessor C Compiler Assembler Linker 2. Compilation is the second pass. It takes the output of the preprocessor and the source code and generates assembler source code. 3. Assembly is the third stage that takes the assembly source code and produces an assembly listing with offsets.The assembler output is stored in an object file. 4. Linking is the final stage that takes one or more object files or libraries as input and combines them to produce a single (executable) file. Library Files Other Object files Relocation object code information
  • 35. Compiling using command prompt: 1. Write your code into a text editor and name the file with .c extention. 2. Add your gcc compiler’s bin directory path into windows environment variables path variable. 3. Open windows command prompt and write the following command gcc –c “path of your .c file with file name” This command will generate the object file with .o extension let, object_file_name.o 4.Then give the following command gcc –o exe_file_name object_file_name.o