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

What's hot

Programming Fundamental Presentation
Programming Fundamental PresentationProgramming Fundamental Presentation
Programming Fundamental Presentation
fazli khaliq
 
Algorithm and pseudo codes
Algorithm and pseudo codesAlgorithm and pseudo codes
Algorithm and pseudo codeshermiraguilar
 
What is an algorithm?
What is an algorithm?What is an algorithm?
What is an algorithm?
Angela DeHart
 
Algorithms and flowcharts
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowcharts
Samuel Igbanogu
 
Data types
Data typesData types
Data types
Nokesh Prabhakar
 
Steps for c program execution
Steps for c program executionSteps for c program execution
Steps for c program execution
Rumman Ansari
 
Programming Fundamentals lecture 1
Programming Fundamentals lecture 1Programming Fundamentals lecture 1
Programming Fundamentals lecture 1
REHAN IJAZ
 
Programming flowcharts for C Language
Programming flowcharts for C LanguageProgramming flowcharts for C Language
Programming flowcharts for C Language
Aryan Ajmer
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
Mohamed Loey
 
ppt of flowchart
ppt of flowchartppt of flowchart
ppt of flowchart
140120109032
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data types
Pratik Devmurari
 
Procedural programming
Procedural programmingProcedural programming
Procedural programming
Ankit92Chitnavis
 
Windows and its components
Windows and its componentsWindows and its components
Windows and its componentsAAi Irene
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
Ahmad Idrees
 
Microsoft word
Microsoft wordMicrosoft word
Microsoft word
RoshanMaharjan13
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programmingNSU-Biliran Campus
 
Flowcharts and algorithms
Flowcharts and algorithmsFlowcharts and algorithms
Flowcharts and algorithms
Student
 
Introduction to c++ ppt
Introduction to c++ pptIntroduction to c++ ppt
Introduction to c++ ppt
Prof. Dr. K. Adisesha
 
Assembly language
Assembly languageAssembly language
Assembly language
shashank puthran
 

What's hot (20)

Programming Fundamental Presentation
Programming Fundamental PresentationProgramming Fundamental Presentation
Programming Fundamental Presentation
 
Algorithm and pseudo codes
Algorithm and pseudo codesAlgorithm and pseudo codes
Algorithm and pseudo codes
 
What is an algorithm?
What is an algorithm?What is an algorithm?
What is an algorithm?
 
Algorithms and flowcharts
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowcharts
 
Data types
Data typesData types
Data types
 
Steps for c program execution
Steps for c program executionSteps for c program execution
Steps for c program execution
 
Programming Fundamentals lecture 1
Programming Fundamentals lecture 1Programming Fundamentals lecture 1
Programming Fundamentals lecture 1
 
Programming flowcharts for C Language
Programming flowcharts for C LanguageProgramming flowcharts for C Language
Programming flowcharts for C Language
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
 
ppt of flowchart
ppt of flowchartppt of flowchart
ppt of flowchart
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data types
 
Procedural programming
Procedural programmingProcedural programming
Procedural programming
 
Translators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreterTranslators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreter
 
Windows and its components
Windows and its componentsWindows and its components
Windows and its components
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
Microsoft word
Microsoft wordMicrosoft word
Microsoft word
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
 
Flowcharts and algorithms
Flowcharts and algorithmsFlowcharts and algorithms
Flowcharts and algorithms
 
Introduction to c++ ppt
Introduction to c++ pptIntroduction to c++ ppt
Introduction to c++ ppt
 
Assembly language
Assembly languageAssembly language
Assembly language
 

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

Practical 01 (detailed)
Practical 01 (detailed)Practical 01 (detailed)
Practical 01 (detailed)
Muhammadalizardari
 
25422733 c-programming-and-data-structures-lab-manual
25422733 c-programming-and-data-structures-lab-manual25422733 c-programming-and-data-structures-lab-manual
25422733 c-programming-and-data-structures-lab-manual
kamesh dagia
 
Solution of matlab chapter 6
Solution of matlab chapter 6Solution of matlab chapter 6
Solution of matlab chapter 6
AhsanIrshad8
 
Cis 170 Extraordinary Success/newtonhelp.com
Cis 170 Extraordinary Success/newtonhelp.com  Cis 170 Extraordinary Success/newtonhelp.com
Cis 170 Extraordinary Success/newtonhelp.com
amaranthbeg143
 
CIS 170 Life of the Mind/newtonhelp.com   
CIS 170 Life of the Mind/newtonhelp.com   CIS 170 Life of the Mind/newtonhelp.com   
CIS 170 Life of the Mind/newtonhelp.com   
llflowe
 
CIS 170 Imagine Your Future/newtonhelp.com   
CIS 170 Imagine Your Future/newtonhelp.com   CIS 170 Imagine Your Future/newtonhelp.com   
CIS 170 Imagine Your Future/newtonhelp.com   
bellflower42
 
Week1 programming challenges
Week1 programming challengesWeek1 programming challenges
Week1 programming challenges
Dhanu Srikar
 
CIS 170 Inspiring Innovation/tutorialrank.com
 CIS 170 Inspiring Innovation/tutorialrank.com CIS 170 Inspiring Innovation/tutorialrank.com
CIS 170 Inspiring Innovation/tutorialrank.com
jonhson110
 
Basic pogramming concepts
Basic pogramming conceptsBasic pogramming concepts
Basic pogramming concepts
Anurag Prajapat
 
CIS 170 Focus Dreams/newtonhelp.com
CIS 170 Focus Dreams/newtonhelp.comCIS 170 Focus Dreams/newtonhelp.com
CIS 170 Focus Dreams/newtonhelp.com
bellflower82
 
CIS 170 Effective Communication - tutorialrank.com
CIS 170 Effective Communication - tutorialrank.comCIS 170 Effective Communication - tutorialrank.com
CIS 170 Effective Communication - tutorialrank.com
Bartholomew19
 
COMP 122 Entire Course NEW
COMP 122 Entire Course NEWCOMP 122 Entire Course NEW
COMP 122 Entire Course NEW
shyamuopeight
 
Programing Fundamental
Programing FundamentalPrograming Fundamental
Programing Fundamental
Qazi Shahzad Ali
 
Basic of c++ programming
Basic of c++ programmingBasic of c++ programming
Basic of c++ programming
Talha Mughal
 
Devry cis-170-c-i lab-1-of-7-getting-started
Devry cis-170-c-i lab-1-of-7-getting-startedDevry cis-170-c-i lab-1-of-7-getting-started
Devry cis-170-c-i lab-1-of-7-getting-started
govendaagoovenda
 
Devry cis-170-c-i lab-1-of-7-getting-started
Devry cis-170-c-i lab-1-of-7-getting-startedDevry cis-170-c-i lab-1-of-7-getting-started
Devry cis-170-c-i lab-1-of-7-getting-started
noahjamessss
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
Rohit Shrivastava
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
Jehangir Khan
 
Mathcad
MathcadMathcad
Mathcad
gaadi221
 

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

Practical 01 (detailed)
Practical 01 (detailed)Practical 01 (detailed)
Practical 01 (detailed)
 
25422733 c-programming-and-data-structures-lab-manual
25422733 c-programming-and-data-structures-lab-manual25422733 c-programming-and-data-structures-lab-manual
25422733 c-programming-and-data-structures-lab-manual
 
Solution of matlab chapter 6
Solution of matlab chapter 6Solution of matlab chapter 6
Solution of matlab chapter 6
 
Cis 170 Extraordinary Success/newtonhelp.com
Cis 170 Extraordinary Success/newtonhelp.com  Cis 170 Extraordinary Success/newtonhelp.com
Cis 170 Extraordinary Success/newtonhelp.com
 
CIS 170 Life of the Mind/newtonhelp.com   
CIS 170 Life of the Mind/newtonhelp.com   CIS 170 Life of the Mind/newtonhelp.com   
CIS 170 Life of the Mind/newtonhelp.com   
 
CIS 170 Imagine Your Future/newtonhelp.com   
CIS 170 Imagine Your Future/newtonhelp.com   CIS 170 Imagine Your Future/newtonhelp.com   
CIS 170 Imagine Your Future/newtonhelp.com   
 
Week1 programming challenges
Week1 programming challengesWeek1 programming challenges
Week1 programming challenges
 
CIS 170 Inspiring Innovation/tutorialrank.com
 CIS 170 Inspiring Innovation/tutorialrank.com CIS 170 Inspiring Innovation/tutorialrank.com
CIS 170 Inspiring Innovation/tutorialrank.com
 
Basic pogramming concepts
Basic pogramming conceptsBasic pogramming concepts
Basic pogramming concepts
 
CIS 170 Focus Dreams/newtonhelp.com
CIS 170 Focus Dreams/newtonhelp.comCIS 170 Focus Dreams/newtonhelp.com
CIS 170 Focus Dreams/newtonhelp.com
 
CIS 170 Effective Communication - tutorialrank.com
CIS 170 Effective Communication - tutorialrank.comCIS 170 Effective Communication - tutorialrank.com
CIS 170 Effective Communication - tutorialrank.com
 
COMP 122 Entire Course NEW
COMP 122 Entire Course NEWCOMP 122 Entire Course NEW
COMP 122 Entire Course NEW
 
Programing Fundamental
Programing FundamentalPrograming Fundamental
Programing Fundamental
 
Basic of c++ programming
Basic of c++ programmingBasic of c++ programming
Basic of c++ programming
 
Cs 1114 - lecture-2
Cs 1114 - lecture-2Cs 1114 - lecture-2
Cs 1114 - lecture-2
 
Devry cis-170-c-i lab-1-of-7-getting-started
Devry cis-170-c-i lab-1-of-7-getting-startedDevry cis-170-c-i lab-1-of-7-getting-started
Devry cis-170-c-i lab-1-of-7-getting-started
 
Devry cis-170-c-i lab-1-of-7-getting-started
Devry cis-170-c-i lab-1-of-7-getting-startedDevry cis-170-c-i lab-1-of-7-getting-started
Devry cis-170-c-i lab-1-of-7-getting-started
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Mathcad
MathcadMathcad
Mathcad
 

More from Mohammad Imam Hossain

DS & Algo 6 - Offline Assignment 6
DS & Algo 6 - Offline Assignment 6DS & Algo 6 - Offline Assignment 6
DS & Algo 6 - Offline Assignment 6
Mohammad Imam Hossain
 
DS & Algo 6 - Dynamic Programming
DS & Algo 6 - Dynamic ProgrammingDS & Algo 6 - Dynamic Programming
DS & Algo 6 - Dynamic Programming
Mohammad Imam Hossain
 
DS & Algo 5 - Disjoint Set and MST
DS & Algo 5 - Disjoint Set and MSTDS & Algo 5 - Disjoint Set and MST
DS & Algo 5 - Disjoint Set and MST
Mohammad Imam Hossain
 
DS & Algo 4 - Graph and Shortest Path Search
DS & Algo 4 - Graph and Shortest Path SearchDS & Algo 4 - Graph and Shortest Path Search
DS & Algo 4 - Graph and Shortest Path Search
Mohammad Imam Hossain
 
DS & Algo 3 - Offline Assignment 3
DS & Algo 3 - Offline Assignment 3DS & Algo 3 - Offline Assignment 3
DS & Algo 3 - Offline Assignment 3
Mohammad Imam Hossain
 
DS & Algo 3 - Divide and Conquer
DS & Algo 3 - Divide and ConquerDS & Algo 3 - Divide and Conquer
DS & Algo 3 - Divide and Conquer
Mohammad Imam Hossain
 
DS & Algo 2 - Offline Assignment 2
DS & Algo 2 - Offline Assignment 2DS & Algo 2 - Offline Assignment 2
DS & Algo 2 - Offline Assignment 2
Mohammad Imam Hossain
 
DS & Algo 2 - Recursion
DS & Algo 2 - RecursionDS & Algo 2 - Recursion
DS & Algo 2 - Recursion
Mohammad Imam Hossain
 
DS & Algo 1 - Offline Assignment 1
DS & Algo 1 - Offline Assignment 1DS & Algo 1 - Offline Assignment 1
DS & Algo 1 - Offline Assignment 1
Mohammad Imam Hossain
 
DS & Algo 1 - C++ and STL Introduction
DS & Algo 1 - C++ and STL IntroductionDS & Algo 1 - C++ and STL Introduction
DS & Algo 1 - C++ and STL Introduction
Mohammad Imam Hossain
 
DBMS 1 | Introduction to DBMS
DBMS 1 | Introduction to DBMSDBMS 1 | Introduction to DBMS
DBMS 1 | Introduction to DBMS
Mohammad Imam Hossain
 
DBMS 10 | Database Transactions
DBMS 10 | Database TransactionsDBMS 10 | Database Transactions
DBMS 10 | Database Transactions
Mohammad Imam Hossain
 
DBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational SchemaDBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational Schema
Mohammad Imam Hossain
 
DBMS 2 | Entity Relationship Model
DBMS 2 | Entity Relationship ModelDBMS 2 | Entity Relationship Model
DBMS 2 | Entity Relationship Model
Mohammad Imam Hossain
 
DBMS 7 | Relational Query Language
DBMS 7 | Relational Query LanguageDBMS 7 | Relational Query Language
DBMS 7 | Relational Query Language
Mohammad Imam Hossain
 
DBMS 4 | MySQL - DDL & DML Commands
DBMS 4 | MySQL - DDL & DML CommandsDBMS 4 | MySQL - DDL & DML Commands
DBMS 4 | MySQL - DDL & DML Commands
Mohammad Imam Hossain
 
DBMS 5 | MySQL Practice List - HR Schema
DBMS 5 | MySQL Practice List - HR SchemaDBMS 5 | MySQL Practice List - HR Schema
DBMS 5 | MySQL Practice List - HR Schema
Mohammad Imam Hossain
 
TOC 10 | Turing Machine
TOC 10 | Turing MachineTOC 10 | Turing Machine
TOC 10 | Turing Machine
Mohammad Imam Hossain
 
TOC 9 | Pushdown Automata
TOC 9 | Pushdown AutomataTOC 9 | Pushdown Automata
TOC 9 | Pushdown Automata
Mohammad Imam Hossain
 
TOC 8 | Derivation, Parse Tree & Ambiguity Check
TOC 8 | Derivation, Parse Tree & Ambiguity CheckTOC 8 | Derivation, Parse Tree & Ambiguity Check
TOC 8 | Derivation, Parse Tree & Ambiguity Check
Mohammad Imam Hossain
 

More from Mohammad Imam Hossain (20)

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

Recently uploaded

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 

Recently uploaded (20)

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 

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