SlideShare uma empresa Scribd logo
1 de 53
Programming
TBE 540
Farah Fisher
Objectives
 After viewing this presentation, the
learner will be able to…
• Given a task, create pseudocode
• Given pseudocode, create a flowchart
• Define/describe these terms: program,
compile vs. interpret, loop, variable, function,
syntax, code, debug, IF THEN ELSE
What is programming?
 Series of instructions to a computer to
accomplish a task
 Instructions must be written in a way the
computer can understand
 Programming languages are used to
write programs
What is programming?
 Once the code (language) of a program
has been written, it must be executed
(run, started).
 You may need to type the name of the
program to start it, or use a word like
RUN and the name of the program (in
the old days, anyway).
What is programming?
 Some programming languages (like Java
or C++) require the code to be compiled
(translated to binary) before it can be
started.
 Others (like JavaScript) are interpreted,
meaning that each command is
translated separately when the program
is started.
What is a programming
language?
 Set of commands that a computer has been
“taught” to understand
 Languages that look like “machine code” (e.g.,
82A8: jsr r5,@#82AE 82AC: sob r0,8296) are used for…
• Writing games
• Writing application programs (like Excel)
 Other languages look like English (“high level,”
e.g., PRINT “HELLO”)
• Logo
• JavaScript
• And many more
What does programming
look like?
 Here are some examples of an instruction to
print the word HI
• Logo PR [HI]
• JavaScript alert(“HI”);
• FORTRAN PRINT “HI”
• BASIC PRINT “HI”
• COBOL DISPLAY ‘HI’.
• C++ printf(“HI”);
• Pascal WRITELN(‘HI’);
• Assembly XPRNT MESSAGE1
Language MESSAGE1 DC ‘HI’
How do you write a program?
 Decide what steps are needed to complete
the task
 Write the steps in pseudocode (written in
English) or as a flowchart (graphic symbols)
 Translate into the programming language
 Try out the program and “debug” it (fix if
necessary)
What is pseudocode?
 List of steps written in English
 Like the instructions for a recipe
 Must be in the right sequence
• Imagine saying “bake the cake” and then “mix
it up”
Sample Pseudocode
 Task: add two numbers
 Pseudocode:
• Start
• Get two numbers
• Add them
• Print the answer
• End
What does a flowchart look like?
 The pseudocode from the previous slide
would look like this as a flowchart:
Start
Get 2 numbers
Add them
Print answer
End
What are those funny symbols?
 START/END
 INPUT/OUTPUT
 PROCESS
 DECISION
What are those funny symbols?
 START/END
 Used at the beginning
and end of each
flowchart.
What are those funny symbols?
 INPUT/OUTPUT
 Shows when
information/data comes
into a program or is
printed out.
What are those funny symbols?
What are those funny symbols?
 PROCESS
 Used to show
calculations, storing of
data in variables, and
other “processes” that
take place within a
program.
What are those funny symbols?
What are those funny symbols?
 DECISION
 Used to show that the
program must decide
whether something
(usually a comparison
between numbers) is
true or false. YES and
NO (or T/F) branches
are usually shown.
What are those funny symbols?
Y
N
X>7?
Another Sample:
Calculating Age
 Pseudocode:
• Start
• Get year born
• Calculate age
• Print age
• If age > 50 print OLD
• End
Another Sample:
Calculating Age
 Flowchart
• Start
• Get year born
• Calculate age
• Print age
• If age > 50 print OLD
• End
Get yr
Calc age
Print age
Age>50?OLD Y
N
Start
End
Elements of a Program
 All programming languages have certain features in
common. For example:
• Variables
• Commands/Syntax (the way commands are structured)
• Loops
• Decisions
• Functions
 Each programming language has a different set of rules
about these features.
Variables
 Variables are part of almost every program.
 A variable is a “place to put data” and is
usually represented by a letter or a word.
(Think of a variable as a Tupperware
container with a label on it.)
 Variable names cannot contain spaces.
 Some programming languages have very
specific limits on variable names.
Variables
 Usually there are several ways to put
information into a variable.
 The most common way is to use the equal
sign (=).
 X = Y + 7 means take the value of Y, add 7,
and put it into X.
 COUNT=COUNT + 2 means take the current
value of COUNT, add 2 to it, and make it the
new value of COUNT.
Variables
 Sometimes you must specify the type of data
that will be placed in a variable.
 Here are some examples of data types:
• Numeric (numbers of all kinds)
• String (text, “strings of letters”)
• Integer (whole numbers)
• Long (large numbers)
• Boolean (true/false)
Variables
 Variables may be classified as global or local.
 A global variable is one that can be shared by
all parts of a program, including any functions
or sub-programs.
 A local variable is one that is used only within
a certain part of the program, for example, only
in one function or sub-program.
Commands/Syntax
 Programming languages are truly
languages.
 They have rules about grammar,
spelling, punctuation, etc.
 You need to learn the rules of a
programming language, just as you
learned to speak and write English.
Loops
 A loop is a repetition of all or part of the
commands in a program.
 A loop often has a counter (a variable)
and continues to repeat a specified
number of times.
 A loop may also continue until a certain
condition is met (e.g., until the end of a
file or until a number reaches a set limit)
Decisions
 You saw a flowchart symbol for
decisions.
 A program often needs to decide
whether something is true or false in
order to see which way to continue.
 Programs often use IF (or IF THEN or IF
THEN ELSE) statements to show a
decision.
Decisions
 An IF statement always has a condition
to check, often a comparison between a
variable and a number.
 The IF statement also must specify what
to do if the condition/comparison is true.
 These instructions (for “true”) may come
after the word THEN, or they may simply
be listed.
Decisions
 In an IF THEN statement, when the
condition is false, the program simply
ignores the THEN commands and
continues to the next line.
 In an IF THEN ELSE statement,
commands are given for both the true
and false conditions.
Functions
 In most programming languages, small sub-
programs are used to perform some of the
tasks.
 These may be called functions, subroutines,
handlers, or other such terms.
 Functions often have names (e.g., getName
or CALCTAX).
Functions
 A function generally gets information from
the main program, performs some task, and
returns information back to the program.
 Functions follow the same rules of syntax, etc.
as the main program.
 JavaScript code is primarily made of a series
of functions.
Hints for Writing Code
 “Code” means writing the program in the
appropriate language
 Be sure the code is exact (spelling,
capitals/lower case, punctuation, etc).
 Write part of the code, try it, then write
more.
Debugging
 To “debug” means to try a program, then fix
any mistakes.
 Virtually no program works the first time you
run it. There are just too many places to
make errors.
 When you are debugging a program, look for
spelling and punctuation errors.
 Fix one error at a time, then try the program
again.
Self-Check
 A computer program is…
• A series of instructions to accomplish
something
• A TV show
• Written in Egyptian hieroglyphics
• Can be written any way you want to
Self-Check
 A computer program is…
• A series of instructions to accomplish
something
• A TV show
• Written in Egyptian hieroglyphics
• Can be written any way you want to
Self-Check
 To “compile” a program means to…
• Translate it into English
• Translate it into binary code
• Pile up the punch cards used for the program
• Run the program as it was written
Self-Check
 To “compile” a program means to…
• Translate it into English
• Translate it into binary code
• Pile up the punch cards used for the program
• Run the program as it was written
Self-Check
 Pseudocode is…
• The program as it is written in a programming
language
• The results of a program that makes secret
codes
• The logic of a program written in English
• The logic of a program shown in a chart
 Pseudocode is…
• The program as it is written in a programming
language
• The results of a program that makes secret
codes
• The logic of a program written in English
• The logic of a program shown in a chart
Self-Check
Self-Check
 The flowchart symbol to perform a
calculation is…
Self-Check
 The flowchart symbol to perform a
calculation is…
Self-Check
 The flowchart symbol to show a decision
is…
Self-Check
 The flowchart symbol to show a decision
is…
Self-Check
 Look at the flowchart section below. If
the variable X is 5, what will print (K or
1st)?
X > 5?
YN
Print “1st”Print “K”
Self-Check
 Look at the flowchart section below. If
the variable X is 5, what will print (K or
1st)?
X > 5?
YN
Print “1st”Print “K”
K will be printed. The answer to the question “Is X greater than 5?”
is NO, since X is equal to (not greater than) 5.
Self-Check
 Choose the correct
flowchart symbol for each
of these statements.
 AGE>65?
 Calc. Tax
 START
 Print NAME
Self-Check
 Choose the correct
flowchart symbol for each
of these statements.
 AGE>65?
 Calc. Tax
 START
 Print NAME
Self-Check
 A function in a program is…
• Something from trigonometry, like
COSINE
• A sub-program, usually performing one
task
• A way to check the accuracy of a program
(a “function check”)
Self-Check
 A function in a program is…
• Something from trigonometry, like
COSINE
• A sub-program, usually performing one
task
• A way to check the accuracy of a program
(a “function check”)
Self-Check
 A variable in a program is…
• A letter or word that represents a place to
store data
• A decision made within a program
• A small sub-program used to find errors
Self-Check
 A variable in a program is…
• A letter or word that represents a place to
store data
• A decision made within a program
• A small sub-program used to find errors
Challenge
 Try to write pseudocode and create a
flowchart for a program that calculates
the average of three grades and prints
the average.
 The word GOOD should be printed only
if the average is more than 80.
Challenge
 Possible pseudocode
• Start
• Get three grades
• Average them
• Print Average
• Average>80?
• If Yes, print GOOD
• End
Challenge
 Possible flowchart
• Start
• Get three grades
• Average them
• Print Average
• Average>80?
• If Yes, print GOOD
• End
START
END
Get 3 grades
Calc avg
Print avg
Avg>80?GOOD
Y
N

Mais conteúdo relacionado

Mais procurados

Programming language
Programming languageProgramming language
Programming languageRajThakuri
 
Programming Fundamentals lecture 1
Programming Fundamentals lecture 1Programming Fundamentals lecture 1
Programming Fundamentals lecture 1REHAN IJAZ
 
Chapter #1 overview of programming and problem solving
Chapter #1 overview of programming and problem solvingChapter #1 overview of programming and problem solving
Chapter #1 overview of programming and problem solvingAbdul Shah
 
Types of Programming Errors
Types of Programming ErrorsTypes of Programming Errors
Types of Programming ErrorsNeha Sharma
 
1 introduction to problem solving and programming
1 introduction to problem solving and programming1 introduction to problem solving and programming
1 introduction to problem solving and programmingRheigh Henley Calderon
 
Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.Md Hossen
 
Basic Computer Programming
Basic Computer ProgrammingBasic Computer Programming
Basic Computer ProgrammingAllen de Castro
 
Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language Md. Imran Hossain Showrov
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchartRabin BK
 
Types of Programming Languages
Types of Programming LanguagesTypes of Programming Languages
Types of Programming LanguagesJuhi Bhoyar
 
Programming Fundamental Presentation
Programming Fundamental PresentationProgramming Fundamental Presentation
Programming Fundamental Presentationfazli khaliq
 
Language processor
Language processorLanguage processor
Language processorAbha Damani
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programmingManoj Tyagi
 
structured programming
structured programmingstructured programming
structured programmingAhmad54321
 
Compiler vs interpreter
Compiler vs interpreterCompiler vs interpreter
Compiler vs interpreterParas Patel
 
Introduction to MS Word
Introduction to MS WordIntroduction to MS Word
Introduction to MS Wordshivamgupta949
 

Mais procurados (20)

Programming language
Programming languageProgramming language
Programming language
 
Programming Fundamentals lecture 1
Programming Fundamentals lecture 1Programming Fundamentals lecture 1
Programming Fundamentals lecture 1
 
Chapter #1 overview of programming and problem solving
Chapter #1 overview of programming and problem solvingChapter #1 overview of programming and problem solving
Chapter #1 overview of programming and problem solving
 
Types of Programming Errors
Types of Programming ErrorsTypes of Programming Errors
Types of Programming Errors
 
Qbasic
QbasicQbasic
Qbasic
 
1 introduction to problem solving and programming
1 introduction to problem solving and programming1 introduction to problem solving and programming
1 introduction to problem solving and programming
 
Interpreted and compiled language
Interpreted and compiled languageInterpreted and compiled language
Interpreted and compiled language
 
Computer Programming
Computer ProgrammingComputer Programming
Computer Programming
 
Python
PythonPython
Python
 
Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.
 
Basic Computer Programming
Basic Computer ProgrammingBasic Computer Programming
Basic Computer Programming
 
Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Types of Programming Languages
Types of Programming LanguagesTypes of Programming Languages
Types of Programming Languages
 
Programming Fundamental Presentation
Programming Fundamental PresentationProgramming Fundamental Presentation
Programming Fundamental Presentation
 
Language processor
Language processorLanguage processor
Language processor
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
structured programming
structured programmingstructured programming
structured programming
 
Compiler vs interpreter
Compiler vs interpreterCompiler vs interpreter
Compiler vs interpreter
 
Introduction to MS Word
Introduction to MS WordIntroduction to MS Word
Introduction to MS Word
 

Semelhante a Programming

Learn Programming with Livecoding.tv http://goo.gl/tIgO1I
Learn Programming with Livecoding.tv http://goo.gl/tIgO1ILearn Programming with Livecoding.tv http://goo.gl/tIgO1I
Learn Programming with Livecoding.tv http://goo.gl/tIgO1Ilivecoding.tv
 
Introduction to Programming and QBasic Tutorial
Introduction to Programming and QBasic TutorialIntroduction to Programming and QBasic Tutorial
Introduction to Programming and QBasic Tutorialnhomz
 
Chapter 5( programming) answer
Chapter 5( programming) answerChapter 5( programming) answer
Chapter 5( programming) answersmkengkilili2011
 
learn computer science.ppt
learn computer science.pptlearn computer science.ppt
learn computer science.pptfaithola1
 
Introduction to programming by MUFIX Commnity
Introduction to programming by MUFIX CommnityIntroduction to programming by MUFIX Commnity
Introduction to programming by MUFIX Commnitymazenet
 
C programming .pptx
C programming .pptxC programming .pptx
C programming .pptxSuhaibKhan62
 
Programming process and flowchart
Programming process and flowchartProgramming process and flowchart
Programming process and flowcharthermiraguilar
 
02 Algorithms and flowcharts - computers.pptx
02 Algorithms and flowcharts - computers.pptx02 Algorithms and flowcharts - computers.pptx
02 Algorithms and flowcharts - computers.pptxarifaqazi2
 
Introduction To Programming
Introduction To ProgrammingIntroduction To Programming
Introduction To Programmingcwarren
 
Visual Programming
Visual ProgrammingVisual Programming
Visual ProgrammingBagzzz
 
Basic computer-programming-2
Basic computer-programming-2Basic computer-programming-2
Basic computer-programming-2lemonmichelangelo
 
Python for Physical Science.pdf
Python for Physical Science.pdfPython for Physical Science.pdf
Python for Physical Science.pdfMarilouANDERSON
 
Switch case and looping statement
Switch case and looping statementSwitch case and looping statement
Switch case and looping statement_jenica
 

Semelhante a Programming (20)

programming.ppt
programming.pptprogramming.ppt
programming.ppt
 
Learn Programming with Livecoding.tv http://goo.gl/tIgO1I
Learn Programming with Livecoding.tv http://goo.gl/tIgO1ILearn Programming with Livecoding.tv http://goo.gl/tIgO1I
Learn Programming with Livecoding.tv http://goo.gl/tIgO1I
 
Algorithms - Introduction to computer programming
Algorithms - Introduction to computer programmingAlgorithms - Introduction to computer programming
Algorithms - Introduction to computer programming
 
Introduction to Programming and QBasic Tutorial
Introduction to Programming and QBasic TutorialIntroduction to Programming and QBasic Tutorial
Introduction to Programming and QBasic Tutorial
 
Chapter 5( programming) answer
Chapter 5( programming) answerChapter 5( programming) answer
Chapter 5( programming) answer
 
learn computer science.ppt
learn computer science.pptlearn computer science.ppt
learn computer science.ppt
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programming
 
Chapter 2- Prog101.ppt
Chapter 2- Prog101.pptChapter 2- Prog101.ppt
Chapter 2- Prog101.ppt
 
Introduction To Programming (2009 2010)
Introduction To Programming (2009 2010)Introduction To Programming (2009 2010)
Introduction To Programming (2009 2010)
 
Introduction to programming by MUFIX Commnity
Introduction to programming by MUFIX CommnityIntroduction to programming by MUFIX Commnity
Introduction to programming by MUFIX Commnity
 
C programming .pptx
C programming .pptxC programming .pptx
C programming .pptx
 
Programming process and flowchart
Programming process and flowchartProgramming process and flowchart
Programming process and flowchart
 
02 Algorithms and flowcharts - computers.pptx
02 Algorithms and flowcharts - computers.pptx02 Algorithms and flowcharts - computers.pptx
02 Algorithms and flowcharts - computers.pptx
 
Introduction To Programming
Introduction To ProgrammingIntroduction To Programming
Introduction To Programming
 
Visual Programming
Visual ProgrammingVisual Programming
Visual Programming
 
SPOS UNIT1 PPTS (1).pptx
SPOS UNIT1 PPTS (1).pptxSPOS UNIT1 PPTS (1).pptx
SPOS UNIT1 PPTS (1).pptx
 
01 Programming Fundamentals.pptx
01 Programming Fundamentals.pptx01 Programming Fundamentals.pptx
01 Programming Fundamentals.pptx
 
Basic computer-programming-2
Basic computer-programming-2Basic computer-programming-2
Basic computer-programming-2
 
Python for Physical Science.pdf
Python for Physical Science.pdfPython for Physical Science.pdf
Python for Physical Science.pdf
 
Switch case and looping statement
Switch case and looping statementSwitch case and looping statement
Switch case and looping statement
 

Último

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 

Último (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 

Programming

  • 2. Objectives  After viewing this presentation, the learner will be able to… • Given a task, create pseudocode • Given pseudocode, create a flowchart • Define/describe these terms: program, compile vs. interpret, loop, variable, function, syntax, code, debug, IF THEN ELSE
  • 3. What is programming?  Series of instructions to a computer to accomplish a task  Instructions must be written in a way the computer can understand  Programming languages are used to write programs
  • 4. What is programming?  Once the code (language) of a program has been written, it must be executed (run, started).  You may need to type the name of the program to start it, or use a word like RUN and the name of the program (in the old days, anyway).
  • 5. What is programming?  Some programming languages (like Java or C++) require the code to be compiled (translated to binary) before it can be started.  Others (like JavaScript) are interpreted, meaning that each command is translated separately when the program is started.
  • 6. What is a programming language?  Set of commands that a computer has been “taught” to understand  Languages that look like “machine code” (e.g., 82A8: jsr r5,@#82AE 82AC: sob r0,8296) are used for… • Writing games • Writing application programs (like Excel)  Other languages look like English (“high level,” e.g., PRINT “HELLO”) • Logo • JavaScript • And many more
  • 7. What does programming look like?  Here are some examples of an instruction to print the word HI • Logo PR [HI] • JavaScript alert(“HI”); • FORTRAN PRINT “HI” • BASIC PRINT “HI” • COBOL DISPLAY ‘HI’. • C++ printf(“HI”); • Pascal WRITELN(‘HI’); • Assembly XPRNT MESSAGE1 Language MESSAGE1 DC ‘HI’
  • 8. How do you write a program?  Decide what steps are needed to complete the task  Write the steps in pseudocode (written in English) or as a flowchart (graphic symbols)  Translate into the programming language  Try out the program and “debug” it (fix if necessary)
  • 9. What is pseudocode?  List of steps written in English  Like the instructions for a recipe  Must be in the right sequence • Imagine saying “bake the cake” and then “mix it up”
  • 10. Sample Pseudocode  Task: add two numbers  Pseudocode: • Start • Get two numbers • Add them • Print the answer • End
  • 11. What does a flowchart look like?  The pseudocode from the previous slide would look like this as a flowchart: Start Get 2 numbers Add them Print answer End
  • 12. What are those funny symbols?  START/END  INPUT/OUTPUT  PROCESS  DECISION
  • 13. What are those funny symbols?  START/END  Used at the beginning and end of each flowchart.
  • 14. What are those funny symbols?  INPUT/OUTPUT  Shows when information/data comes into a program or is printed out. What are those funny symbols?
  • 15. What are those funny symbols?  PROCESS  Used to show calculations, storing of data in variables, and other “processes” that take place within a program. What are those funny symbols?
  • 16. What are those funny symbols?  DECISION  Used to show that the program must decide whether something (usually a comparison between numbers) is true or false. YES and NO (or T/F) branches are usually shown. What are those funny symbols? Y N X>7?
  • 17. Another Sample: Calculating Age  Pseudocode: • Start • Get year born • Calculate age • Print age • If age > 50 print OLD • End
  • 18. Another Sample: Calculating Age  Flowchart • Start • Get year born • Calculate age • Print age • If age > 50 print OLD • End Get yr Calc age Print age Age>50?OLD Y N Start End
  • 19. Elements of a Program  All programming languages have certain features in common. For example: • Variables • Commands/Syntax (the way commands are structured) • Loops • Decisions • Functions  Each programming language has a different set of rules about these features.
  • 20. Variables  Variables are part of almost every program.  A variable is a “place to put data” and is usually represented by a letter or a word. (Think of a variable as a Tupperware container with a label on it.)  Variable names cannot contain spaces.  Some programming languages have very specific limits on variable names.
  • 21. Variables  Usually there are several ways to put information into a variable.  The most common way is to use the equal sign (=).  X = Y + 7 means take the value of Y, add 7, and put it into X.  COUNT=COUNT + 2 means take the current value of COUNT, add 2 to it, and make it the new value of COUNT.
  • 22. Variables  Sometimes you must specify the type of data that will be placed in a variable.  Here are some examples of data types: • Numeric (numbers of all kinds) • String (text, “strings of letters”) • Integer (whole numbers) • Long (large numbers) • Boolean (true/false)
  • 23. Variables  Variables may be classified as global or local.  A global variable is one that can be shared by all parts of a program, including any functions or sub-programs.  A local variable is one that is used only within a certain part of the program, for example, only in one function or sub-program.
  • 24. Commands/Syntax  Programming languages are truly languages.  They have rules about grammar, spelling, punctuation, etc.  You need to learn the rules of a programming language, just as you learned to speak and write English.
  • 25. Loops  A loop is a repetition of all or part of the commands in a program.  A loop often has a counter (a variable) and continues to repeat a specified number of times.  A loop may also continue until a certain condition is met (e.g., until the end of a file or until a number reaches a set limit)
  • 26. Decisions  You saw a flowchart symbol for decisions.  A program often needs to decide whether something is true or false in order to see which way to continue.  Programs often use IF (or IF THEN or IF THEN ELSE) statements to show a decision.
  • 27. Decisions  An IF statement always has a condition to check, often a comparison between a variable and a number.  The IF statement also must specify what to do if the condition/comparison is true.  These instructions (for “true”) may come after the word THEN, or they may simply be listed.
  • 28. Decisions  In an IF THEN statement, when the condition is false, the program simply ignores the THEN commands and continues to the next line.  In an IF THEN ELSE statement, commands are given for both the true and false conditions.
  • 29. Functions  In most programming languages, small sub- programs are used to perform some of the tasks.  These may be called functions, subroutines, handlers, or other such terms.  Functions often have names (e.g., getName or CALCTAX).
  • 30. Functions  A function generally gets information from the main program, performs some task, and returns information back to the program.  Functions follow the same rules of syntax, etc. as the main program.  JavaScript code is primarily made of a series of functions.
  • 31. Hints for Writing Code  “Code” means writing the program in the appropriate language  Be sure the code is exact (spelling, capitals/lower case, punctuation, etc).  Write part of the code, try it, then write more.
  • 32. Debugging  To “debug” means to try a program, then fix any mistakes.  Virtually no program works the first time you run it. There are just too many places to make errors.  When you are debugging a program, look for spelling and punctuation errors.  Fix one error at a time, then try the program again.
  • 33. Self-Check  A computer program is… • A series of instructions to accomplish something • A TV show • Written in Egyptian hieroglyphics • Can be written any way you want to
  • 34. Self-Check  A computer program is… • A series of instructions to accomplish something • A TV show • Written in Egyptian hieroglyphics • Can be written any way you want to
  • 35. Self-Check  To “compile” a program means to… • Translate it into English • Translate it into binary code • Pile up the punch cards used for the program • Run the program as it was written
  • 36. Self-Check  To “compile” a program means to… • Translate it into English • Translate it into binary code • Pile up the punch cards used for the program • Run the program as it was written
  • 37. Self-Check  Pseudocode is… • The program as it is written in a programming language • The results of a program that makes secret codes • The logic of a program written in English • The logic of a program shown in a chart
  • 38.  Pseudocode is… • The program as it is written in a programming language • The results of a program that makes secret codes • The logic of a program written in English • The logic of a program shown in a chart Self-Check
  • 39. Self-Check  The flowchart symbol to perform a calculation is…
  • 40. Self-Check  The flowchart symbol to perform a calculation is…
  • 41. Self-Check  The flowchart symbol to show a decision is…
  • 42. Self-Check  The flowchart symbol to show a decision is…
  • 43. Self-Check  Look at the flowchart section below. If the variable X is 5, what will print (K or 1st)? X > 5? YN Print “1st”Print “K”
  • 44. Self-Check  Look at the flowchart section below. If the variable X is 5, what will print (K or 1st)? X > 5? YN Print “1st”Print “K” K will be printed. The answer to the question “Is X greater than 5?” is NO, since X is equal to (not greater than) 5.
  • 45. Self-Check  Choose the correct flowchart symbol for each of these statements.  AGE>65?  Calc. Tax  START  Print NAME
  • 46. Self-Check  Choose the correct flowchart symbol for each of these statements.  AGE>65?  Calc. Tax  START  Print NAME
  • 47. Self-Check  A function in a program is… • Something from trigonometry, like COSINE • A sub-program, usually performing one task • A way to check the accuracy of a program (a “function check”)
  • 48. Self-Check  A function in a program is… • Something from trigonometry, like COSINE • A sub-program, usually performing one task • A way to check the accuracy of a program (a “function check”)
  • 49. Self-Check  A variable in a program is… • A letter or word that represents a place to store data • A decision made within a program • A small sub-program used to find errors
  • 50. Self-Check  A variable in a program is… • A letter or word that represents a place to store data • A decision made within a program • A small sub-program used to find errors
  • 51. Challenge  Try to write pseudocode and create a flowchart for a program that calculates the average of three grades and prints the average.  The word GOOD should be printed only if the average is more than 80.
  • 52. Challenge  Possible pseudocode • Start • Get three grades • Average them • Print Average • Average>80? • If Yes, print GOOD • End
  • 53. Challenge  Possible flowchart • Start • Get three grades • Average them • Print Average • Average>80? • If Yes, print GOOD • End START END Get 3 grades Calc avg Print avg Avg>80?GOOD Y N