SlideShare ist ein Scribd-Unternehmen logo
1 von 38
Introduction
     to
Programming
Computer Program
• A computer program is nothing more
than a list of instructions that tell the
computer what to do.
• A computer program is an organized
list of instructions that are designed to
cause the computer to behave in
predetermined manner in order to
accomplish a task.



                           Introduction to Programming
Computer Program
      Windows      OS      with     all    its
icons, toolbars, and menus is really
nothing more than a series of instructions
that the computer follows each time you
press a button, click on a menu, or
respond to a dialog box.
      At the base level, all programs
accept input from the user, process the
data, and display, save or print the results.


                             Introduction to Programming
Goals of a Program

• Be easily read and understood
• Be easy to correct if problems arise
• Be easy to modify as elements in
  the task may change
• Function as it was intended, to
  solve a specific problem or perform
  a specific task


                        Introduction to Programming
Programming
         Language
     A programming language is a
vocabulary and set of grammatical
rules for instructing a computer to
perform specific tasks.
     These grammatical rules are
also called the syntax of the
language.


                      Introduction to Programming
Programming
         Languages
1.   Machine languages
2.   Assembly languages
3.   High-level languages
4.   Fourth-generation languages




                      Introduction to Programming
Machine languages
  Machine languages use binary to
provide instructions to the computer.
  Machine languages are not
common today as they are specific to
each CPU and require long lists of
zeros and ones.
  These programs are very difficult to
write and very error-prone.

                        Introduction to Programming
Assembly languages
   Assembly languages use a special
representation of instructions to give
the computer instructions.
   These languages are only used by
programmers developing complicated
processes like operating systems.




                        Introduction to Programming
High-level languages
       High-level languages use English-
like commands to give instructions.
       They include
BASIC, Pascal, C, C+, C++, COBOL, Java,
 JavaScript and Fortran.
       Of course, the computer does not
speak English.
       It speaks binary, therefore the
programming instructions written in a high-
level language must be converted into
binary using a compiler or interpreter.


                           Introduction to Programming
Interpreters vs.
           Compilers
      Interpreters translate programs
one line at a time while compilers
convert a whole file or program at
once and then generate a separate
executable file.
      The executable file usually ends
with the extension .exe and can be
run without the programming
language.

                        Introduction to Programming
Fourth-generation
          languages
     Fourth-generation languages are
languages that write code for the user
through a series of menus and
prompts.
     Some examples of fourth
generation languages include
ORACLE, and Visual BASIC.



                        Introduction to Programming
Common Features of
Programming Languages

   There are many programming
languages that can be used to
create a computer program.
   Each of these languages has
different syntax.
   However, a basic set of
instructions is always present in
any programming language.

                      Introduction to Programming
Basic Set of Instructions

1. Input
2. Output
3. Mathematics
4. Conditional execution
5. Repetition




                     Introduction to Programming
BASIC Language

   BASIC stands for Beginner's All-
Purpose Symbolic Instruction Code.
   It is developed in the mid-1960s
at Dartmouth College by Professors
John G. Kemeny and Thomas E.
Kurtz.



                      Introduction to Programming
Why Study BASIC?
   When you learn BASIC, you also
learn many of the fundamentals of
other programming languages.
   You can also create programs
easily.
   Once you get into it, you'll find
that the fun in creating programs is
worth coming back to.

                     Introduction to Programming
QBASIC
   QBASIC is a programming
language written for computers back
in 1975, by Bill Gates and Paul Allen.




                        Introduction to Programming
Filename
                       Menu Bar




Immediate
 Window
WORK AREA
FORMAT IN WRITING
  PROGRAM LINES

LINE NO. PROGRAM STATEMENT


     10 CLS

     Space
10 CLS
500 END
10 CLS
20 DISPLAY 12
500 END
Errors in Programming
       If you made any mistakes you will be
given an error message.
       The error message, also called a
diagnostic message, will indicate the line
number and a description of the error.
       At this point, you will have to do what
is called debugging.
       Programmers spend a great deal of
time debugging programs.


                           Introduction to Programming
Debugging
      Debugging is the process of
finding and fixing errors in a program.
      The word debugging comes
from a common computer problem in
the 50's. Bugs would fly inside the
computer.
      Technicians had to find and
remove them in order for the system
to work.This word is still in use today.

                       Introduction to Programming
Types of Programming
          Errors
1. Syntax errors
2. Logic errors




                   Introduction to Programming
Syntax Error
    A syntax error is a mistake in the
grammar or structure of a command.
      For example, in QBASIC, the syntax
for PRINT says you must type PRINT, a
space, and then the literal, number or
expression.
      If by mistake you omit the command
PRINT, then the command will not work.
This is a syntax error.

                         Introduction to Programming
Syntax Error

     All syntax errors are captured by
the compiler or interpreter.
     When you get a syntax error in
your program, you should read and
decipher the error message, then
move to the line identified and fix the
error.


                       Introduction to Programming
Logic Error
       A logic error is much more difficult to isolate
and fix.
        A logic error is a mistake that the compiler
or interpreter cannot identify.
       This kind of error occurs when your
instructions have no syntax error, but the program
does not accomplish its intended purpose.
       For example, if you were asked to find the
area of a circle, but instead calculated the
circumference of a circle, then you would have a
logic error.

                               Introduction to Programming
Correcting Logic Error
       The only way to determine a logic
error is to test your program.
       You should check if the program
works correctly, figure out what the answer
should be (on your own), then check your
answer with the result the program
provides.
       If the computer provides a wrong
answer, then you will have to examine your
program to locate and fix the error.

                         Introduction to Programming
Save your program!
      Once you have found your error and
corrected it, rerun your program.
       When all errors are fixed, save the
file. To do this, press ALT + F (“File“) and
then press S("Save“). Your file will be
saved with the name you provide and will
end with the extension .bas.
       The maximum number of characters
for the QBASIC program filename is eight.

                           Introduction to Programming
10 CLS
20 DISPLAY 12
500 END
10 CLS
20 PRINT 12
500 END




  Change 12 by any number
10 CLS
20 PRINT LORA
500 END
Recall your Algebra!

Constants and Variables
Constants are represented by
    numerals.
Examples: 5, -3, 4.56, - 13.9
Variables are represented by letters.
Examples: x, y, n, C, F



                      Introduction to Programming
Recall MS Excel!
MS Excel Formula

In MS Excel, a cell can contain
    formula.
Example: Cell C1 contains =A1 * B1
A1 and B1 are cell addresses.
They can be used as variables in a
    formula.



                      Introduction to Programming
Variable Names

In Algebra, x + y means x is
     increased by y.
In Algebra, xy is the product of x and
     y.
In QBASIC, xy is only a single
     variable name and NOT a
     product of x and y.


                       Introduction to Programming
10 CLS
20 PRINT LORA
500 END
QBASIC COMMANDS
1. CLS – clears the screen
2. END – terminates the program
3. PRINT – displays the result of
   computer processing




                     Introduction to Programming

Weitere ähnliche Inhalte

Was ist angesagt?

4 evolution-of-programming-languages
4 evolution-of-programming-languages4 evolution-of-programming-languages
4 evolution-of-programming-languages
Rohit Shrivastava
 
Computer Fundamentals Chapter 12 cl
Computer Fundamentals Chapter 12 clComputer Fundamentals Chapter 12 cl
Computer Fundamentals Chapter 12 cl
Saumya Sahu
 
Machine language
Machine languageMachine language
Machine language
Ripal Dhruv
 
La 5 Programming2
La 5   Programming2La 5   Programming2
La 5 Programming2
Cma Mohd
 

Was ist angesagt? (20)

Basic Programming Concept
Basic Programming ConceptBasic Programming Concept
Basic Programming Concept
 
Programming languages of computer
Programming languages of computerProgramming languages of computer
Programming languages of computer
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
 
4 evolution-of-programming-languages
4 evolution-of-programming-languages4 evolution-of-programming-languages
4 evolution-of-programming-languages
 
Computer languages
Computer languagesComputer languages
Computer languages
 
High Level Language (HLL)
High Level Language (HLL)High Level Language (HLL)
High Level Language (HLL)
 
Chapter 4 computer language
Chapter 4 computer languageChapter 4 computer language
Chapter 4 computer language
 
Computer Programming - Lecture 1
Computer Programming - Lecture 1Computer Programming - Lecture 1
Computer Programming - Lecture 1
 
BASIC Programming Language
BASIC Programming LanguageBASIC Programming Language
BASIC Programming Language
 
Programming languages and concepts by vivek parihar
Programming languages and concepts by vivek pariharProgramming languages and concepts by vivek parihar
Programming languages and concepts by vivek parihar
 
Computer Fundamentals Chapter 12 cl
Computer Fundamentals Chapter 12 clComputer Fundamentals Chapter 12 cl
Computer Fundamentals Chapter 12 cl
 
Programming languages
Programming languagesProgramming languages
Programming languages
 
Computer languages
Computer languagesComputer languages
Computer languages
 
Machine language
Machine languageMachine language
Machine language
 
Lecture 8
Lecture 8Lecture 8
Lecture 8
 
Copmuter Languages
Copmuter LanguagesCopmuter Languages
Copmuter Languages
 
Introduction to Programming Languages
Introduction to Programming LanguagesIntroduction to Programming Languages
Introduction to Programming Languages
 
La 5 Programming2
La 5   Programming2La 5   Programming2
La 5 Programming2
 
Programming Languages / Translators
Programming Languages / TranslatorsProgramming Languages / Translators
Programming Languages / Translators
 
introduction computer programming languages
introduction computer programming languages introduction computer programming languages
introduction computer programming languages
 

Andere mochten auch

Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
Varun Garg
 
11 ds and algorithm session_16
11 ds and algorithm session_1611 ds and algorithm session_16
11 ds and algorithm session_16
Niit Care
 
Vb.net session 09
Vb.net session 09Vb.net session 09
Vb.net session 09
Niit Care
 
15 ooad uml-20
15 ooad uml-2015 ooad uml-20
15 ooad uml-20
Niit Care
 
09 iec t1_s1_oo_ps_session_13
09 iec t1_s1_oo_ps_session_1309 iec t1_s1_oo_ps_session_13
09 iec t1_s1_oo_ps_session_13
Niit Care
 
Jdbc session01
Jdbc session01Jdbc session01
Jdbc session01
Niit Care
 
14 ooad uml-19
14 ooad uml-1914 ooad uml-19
14 ooad uml-19
Niit Care
 
Deawsj 7 ppt-2_c
Deawsj 7 ppt-2_cDeawsj 7 ppt-2_c
Deawsj 7 ppt-2_c
Niit Care
 

Andere mochten auch (20)

Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
 
Introduction to-programming
Introduction to-programmingIntroduction to-programming
Introduction to-programming
 
Dacj 1-1 a
Dacj 1-1 aDacj 1-1 a
Dacj 1-1 a
 
Presentation of programming languages for beginners
Presentation of programming languages for beginnersPresentation of programming languages for beginners
Presentation of programming languages for beginners
 
Introduction of Programming language
Introduction of Programming languageIntroduction of Programming language
Introduction of Programming language
 
Dacj 2-2 c
Dacj 2-2 cDacj 2-2 c
Dacj 2-2 c
 
 
Oops recap
Oops recapOops recap
Oops recap
 
11 ds and algorithm session_16
11 ds and algorithm session_1611 ds and algorithm session_16
11 ds and algorithm session_16
 
Vb.net session 09
Vb.net session 09Vb.net session 09
Vb.net session 09
 
15 ooad uml-20
15 ooad uml-2015 ooad uml-20
15 ooad uml-20
 
09 iec t1_s1_oo_ps_session_13
09 iec t1_s1_oo_ps_session_1309 iec t1_s1_oo_ps_session_13
09 iec t1_s1_oo_ps_session_13
 
OOP Java
OOP JavaOOP Java
OOP Java
 
Rdbms xp 01
Rdbms xp 01Rdbms xp 01
Rdbms xp 01
 
Jdbc session01
Jdbc session01Jdbc session01
Jdbc session01
 
Tugas Pw [6]
Tugas Pw [6]Tugas Pw [6]
Tugas Pw [6]
 
Add a web server
Add a web serverAdd a web server
Add a web server
 
14 ooad uml-19
14 ooad uml-1914 ooad uml-19
14 ooad uml-19
 
The web and programming: an introduction - Simple, short and friendly
The web and programming: an introduction - Simple, short and friendly The web and programming: an introduction - Simple, short and friendly
The web and programming: an introduction - Simple, short and friendly
 
Deawsj 7 ppt-2_c
Deawsj 7 ppt-2_cDeawsj 7 ppt-2_c
Deawsj 7 ppt-2_c
 

Ähnlich wie Introduction to programming

La5 ict-topic-5-programming
La5 ict-topic-5-programmingLa5 ict-topic-5-programming
La5 ict-topic-5-programming
Kak Yong
 
Introduction to Programming Concepts By Aamir Saleem Ansari
Introduction to Programming Concepts By Aamir Saleem AnsariIntroduction to Programming Concepts By Aamir Saleem Ansari
Introduction to Programming Concepts By Aamir Saleem Ansari
Tech
 
Programming lesson1
Programming lesson1Programming lesson1
Programming lesson1
camfollower
 

Ähnlich wie Introduction to programming (20)

Ic lecture8
Ic lecture8 Ic lecture8
Ic lecture8
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & Languages
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & Languages
 
Chapter 2.pptx
Chapter 2.pptxChapter 2.pptx
Chapter 2.pptx
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Programming in c
Programming in cProgramming in c
Programming in c
 
Programming in C
Programming in CProgramming in C
Programming in C
 
Comso c++
Comso c++Comso c++
Comso c++
 
La5 ict-topic-5-programming
La5 ict-topic-5-programmingLa5 ict-topic-5-programming
La5 ict-topic-5-programming
 
Introduction to Computer
Introduction to ComputerIntroduction to Computer
Introduction to Computer
 
C.pdf
C.pdfC.pdf
C.pdf
 
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfINTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
 
Computer languages
Computer languagesComputer languages
Computer languages
 
Introduction to Computers Lecture # 12
Introduction to Computers Lecture # 12Introduction to Computers Lecture # 12
Introduction to Computers Lecture # 12
 
Software programming and development
Software programming and developmentSoftware programming and development
Software programming and development
 
Introduction to Programming Concepts By Aamir Saleem Ansari
Introduction to Programming Concepts By Aamir Saleem AnsariIntroduction to Programming Concepts By Aamir Saleem Ansari
Introduction to Programming Concepts By Aamir Saleem Ansari
 
Ppt 1
Ppt 1Ppt 1
Ppt 1
 
Programming lesson1
Programming lesson1Programming lesson1
Programming lesson1
 
Introduction to systems programming
Introduction to systems programmingIntroduction to systems programming
Introduction to systems programming
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programming
 

Kürzlich hochgeladen

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 

Kürzlich hochgeladen (20)

How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 

Introduction to programming

  • 1. Introduction to Programming
  • 2. Computer Program • A computer program is nothing more than a list of instructions that tell the computer what to do. • A computer program is an organized list of instructions that are designed to cause the computer to behave in predetermined manner in order to accomplish a task. Introduction to Programming
  • 3. Computer Program Windows OS with all its icons, toolbars, and menus is really nothing more than a series of instructions that the computer follows each time you press a button, click on a menu, or respond to a dialog box. At the base level, all programs accept input from the user, process the data, and display, save or print the results. Introduction to Programming
  • 4. Goals of a Program • Be easily read and understood • Be easy to correct if problems arise • Be easy to modify as elements in the task may change • Function as it was intended, to solve a specific problem or perform a specific task Introduction to Programming
  • 5. Programming Language A programming language is a vocabulary and set of grammatical rules for instructing a computer to perform specific tasks. These grammatical rules are also called the syntax of the language. Introduction to Programming
  • 6. Programming Languages 1. Machine languages 2. Assembly languages 3. High-level languages 4. Fourth-generation languages Introduction to Programming
  • 7. Machine languages Machine languages use binary to provide instructions to the computer. Machine languages are not common today as they are specific to each CPU and require long lists of zeros and ones. These programs are very difficult to write and very error-prone. Introduction to Programming
  • 8. Assembly languages Assembly languages use a special representation of instructions to give the computer instructions. These languages are only used by programmers developing complicated processes like operating systems. Introduction to Programming
  • 9. High-level languages High-level languages use English- like commands to give instructions. They include BASIC, Pascal, C, C+, C++, COBOL, Java, JavaScript and Fortran. Of course, the computer does not speak English. It speaks binary, therefore the programming instructions written in a high- level language must be converted into binary using a compiler or interpreter. Introduction to Programming
  • 10. Interpreters vs. Compilers Interpreters translate programs one line at a time while compilers convert a whole file or program at once and then generate a separate executable file. The executable file usually ends with the extension .exe and can be run without the programming language. Introduction to Programming
  • 11. Fourth-generation languages Fourth-generation languages are languages that write code for the user through a series of menus and prompts. Some examples of fourth generation languages include ORACLE, and Visual BASIC. Introduction to Programming
  • 12. Common Features of Programming Languages There are many programming languages that can be used to create a computer program. Each of these languages has different syntax. However, a basic set of instructions is always present in any programming language. Introduction to Programming
  • 13. Basic Set of Instructions 1. Input 2. Output 3. Mathematics 4. Conditional execution 5. Repetition Introduction to Programming
  • 14. BASIC Language BASIC stands for Beginner's All- Purpose Symbolic Instruction Code. It is developed in the mid-1960s at Dartmouth College by Professors John G. Kemeny and Thomas E. Kurtz. Introduction to Programming
  • 15. Why Study BASIC? When you learn BASIC, you also learn many of the fundamentals of other programming languages. You can also create programs easily. Once you get into it, you'll find that the fun in creating programs is worth coming back to. Introduction to Programming
  • 16. QBASIC QBASIC is a programming language written for computers back in 1975, by Bill Gates and Paul Allen. Introduction to Programming
  • 17. Filename Menu Bar Immediate Window
  • 19. FORMAT IN WRITING PROGRAM LINES LINE NO. PROGRAM STATEMENT 10 CLS Space
  • 21. 10 CLS 20 DISPLAY 12 500 END
  • 22. Errors in Programming If you made any mistakes you will be given an error message. The error message, also called a diagnostic message, will indicate the line number and a description of the error. At this point, you will have to do what is called debugging. Programmers spend a great deal of time debugging programs. Introduction to Programming
  • 23. Debugging Debugging is the process of finding and fixing errors in a program. The word debugging comes from a common computer problem in the 50's. Bugs would fly inside the computer. Technicians had to find and remove them in order for the system to work.This word is still in use today. Introduction to Programming
  • 24. Types of Programming Errors 1. Syntax errors 2. Logic errors Introduction to Programming
  • 25. Syntax Error A syntax error is a mistake in the grammar or structure of a command. For example, in QBASIC, the syntax for PRINT says you must type PRINT, a space, and then the literal, number or expression. If by mistake you omit the command PRINT, then the command will not work. This is a syntax error. Introduction to Programming
  • 26. Syntax Error All syntax errors are captured by the compiler or interpreter. When you get a syntax error in your program, you should read and decipher the error message, then move to the line identified and fix the error. Introduction to Programming
  • 27. Logic Error A logic error is much more difficult to isolate and fix. A logic error is a mistake that the compiler or interpreter cannot identify. This kind of error occurs when your instructions have no syntax error, but the program does not accomplish its intended purpose. For example, if you were asked to find the area of a circle, but instead calculated the circumference of a circle, then you would have a logic error. Introduction to Programming
  • 28. Correcting Logic Error The only way to determine a logic error is to test your program. You should check if the program works correctly, figure out what the answer should be (on your own), then check your answer with the result the program provides. If the computer provides a wrong answer, then you will have to examine your program to locate and fix the error. Introduction to Programming
  • 29. Save your program! Once you have found your error and corrected it, rerun your program. When all errors are fixed, save the file. To do this, press ALT + F (“File“) and then press S("Save“). Your file will be saved with the name you provide and will end with the extension .bas. The maximum number of characters for the QBASIC program filename is eight. Introduction to Programming
  • 30. 10 CLS 20 DISPLAY 12 500 END
  • 31. 10 CLS 20 PRINT 12 500 END Change 12 by any number
  • 32. 10 CLS 20 PRINT LORA 500 END
  • 33. Recall your Algebra! Constants and Variables Constants are represented by numerals. Examples: 5, -3, 4.56, - 13.9 Variables are represented by letters. Examples: x, y, n, C, F Introduction to Programming
  • 35. MS Excel Formula In MS Excel, a cell can contain formula. Example: Cell C1 contains =A1 * B1 A1 and B1 are cell addresses. They can be used as variables in a formula. Introduction to Programming
  • 36. Variable Names In Algebra, x + y means x is increased by y. In Algebra, xy is the product of x and y. In QBASIC, xy is only a single variable name and NOT a product of x and y. Introduction to Programming
  • 37. 10 CLS 20 PRINT LORA 500 END
  • 38. QBASIC COMMANDS 1. CLS – clears the screen 2. END – terminates the program 3. PRINT – displays the result of computer processing Introduction to Programming