Introduction to QBASIC Programming Mahesh Sharma, B.Sc. (Hons) Computing Copyright © 2017. © mahesh
Agendas Today  Introduction  Program and Programming Tools  Algorithm and Flowchart  Concept of QBASIC Programming  Structure of QBASIC  Constants and Variables  Arithmetic and Relational Expressions  Logical Operators  Keywords and Syntax  Library Function in QBASIC © mahesh
Introduction  Computer system needs instructions to perform different tasks.  These instructions are called command. A collection or set of commands composes a program.  Computer program are written using programming languages in order to solves specific problem.  Some of the popular examples of programming languages are: % QBASIC, C, C++, Java, PHP, MySql, .NET etc. © mahesh
Program and Programming Tools  Program is the collection of commands in systematic order to perform specific tasks  Programming is a technique or art to develop the program  Programmer is a person who develops the program using programming language  Programmers use programming tools to develop a program. Algorithm and Flowchart are most popular programming tools and technique to write a program © mahesh
Algorithm Step by Step Description of Program in Systematic Order Source: http://images.slideplayer.com/35/10459273/slides/slide_16.jpg © mahesh
Rules for Good Algorithm Input : specified and required input values Output : outcome values or solution of problem Definite : must be defined clearly about what should be done Effective : must be able to perform each step exactly in finite amount of time Finite : finite number of steps Correct : must be able to generate correct and desirable output Algorithm © mahesh
Algorithm and Flowchart Diagrammatic representation of a program using standard symbols © mahesh
Flowchart Symbols The basic flowchart symbols © mahesh
FlowchartTypes System Flowchart Represents the system and its components Sequence of instructions to solve specific work Explains the total flow of data inside the system Complex logical structure diagram Program Flowchart  Represents program and its components  Sequence of instructions to solve specific problem  Explains the instructions to solve the problem  Relatively easier logical structure diagram. © mahesh
Advantages of Flowchart © mahesh  Easy method to Understand and Communicate  Easier approach than Algorithm and Coding  Applicable to all types of programming languages  Represents all the components of program like input, process, logic and output  Serves as a guide to programmers
Disadvantages of Flowchart © mahesh  Cannot replace all types of logics used in computer program  Takes long time to represent all components of computer Program  Not applicable for complex and big types of program or System
Program Logic or Structure Program consists of different types of logic or structures based on the solution to the identified problems. 3 types of Program Logic or Structures are: i. Sequence : set of instructions which are executed one after another in a steps ii. Selection : set of instructions which are executed conditionally based on conditions that are either true or false iii. Iteration : set of instructions which are executed repeatedly and conditionally by loop conditions © mahesh
Programming in QBASIC QBASIC is the most popular high level programming language. Developed by Microsoft Company, USA. Q => Quick B => Beginners A => All Purpose S => Symbolic I => Instruction C => Code Consists of two basic files QBASIC.EXE and QBASIC.HLP For editing, debugging and executing programs © mahesh
Structure of QBASIC © mahesh Structure consists of some of the standard programming elements. They are:  Character Set  Variable and Constants  Arithmetic Expressions  Relational or Logical Expressions  Keywords and Syntax  Library Functions  Conclusion
Character Set in QBASIC © mahesh Character set in QBASIC consists following standard elements:  Alphabet : (a-z), (A – Z)  Digits : 0, 1, 2, ……….., 9 and  Special Characters : + - * / () . , : ; > < “ ! @ $ etc.
Variable and Constants © mahesh Variable and Constants are the memory location of the programming data. However they both are different based on value in computer memory space. i. Constant : Quantity whose value does not change during program execution ii. Variable : Quantity whose value may change during program execution Types of Variable: a. Numeric Constant/Variable b. String Constant/ Variable
Arithmetic Expressions © mahesh Arithmetic Expressions are the five basic mathematical expressions used in QBASIC. They are: i. Exponentiation (^) ii. Multiplication (*) and Division (/) iii. Addition (+) and Subtraction (-) Follows General BODMAS Rule QBASIC follows the hierarchy according to the mathematical algebraic rules and regulations
Relational Expressions © mahesh Relational Expressions are the formed by using following relational operators in QBASIC:
Logical Expressions © mahesh Logical Expressions are the formed by using two or more expressions to return value TRUE or FALSE: The common logical operators are: i) AND ii) OR iii) NOT Conjunction Disjunction Logical Negation The result for two expressions A and B using the common logical operators:
Keywords and Syntax © mahesh Keywords in QBASIC are the special types of variables that are not applicable to use in computer program. Also called reserved words by QBASIC. For example: INPUT, PRINT, CLS, GOTO, IF, FOR, WHILE, END, ENDIF, LET, etc. Syntax is the set of rules and regulations that must be followed to construct the program in QBASIC programming. Also called Grammar for writing command and statement in developing computer program.
Library Function © mahesh  ‘Library’ stands for collection in general  Library Functions in QBASIC is the set or collection of useful programs and instructions.  Used to simplify the task of programmers.  QBASIC library is rich with mathematical functions like square root, log of number, sine of angle, etc. For example: SQR(), LOG(), SIN(), etc.
Introduction to QBASIC Programming © mahesh Any Questions
© mahesh

Introduction to QBASIC programming and basics

  • 1.
    Introduction to QBASICProgramming Mahesh Sharma, B.Sc. (Hons) Computing Copyright © 2017. © mahesh
  • 2.
    Agendas Today  Introduction Program and Programming Tools  Algorithm and Flowchart  Concept of QBASIC Programming  Structure of QBASIC  Constants and Variables  Arithmetic and Relational Expressions  Logical Operators  Keywords and Syntax  Library Function in QBASIC © mahesh
  • 3.
    Introduction  Computer systemneeds instructions to perform different tasks.  These instructions are called command. A collection or set of commands composes a program.  Computer program are written using programming languages in order to solves specific problem.  Some of the popular examples of programming languages are: % QBASIC, C, C++, Java, PHP, MySql, .NET etc. © mahesh
  • 4.
    Program and ProgrammingTools  Program is the collection of commands in systematic order to perform specific tasks  Programming is a technique or art to develop the program  Programmer is a person who develops the program using programming language  Programmers use programming tools to develop a program. Algorithm and Flowchart are most popular programming tools and technique to write a program © mahesh
  • 5.
    Algorithm Step by StepDescription of Program in Systematic Order Source: http://images.slideplayer.com/35/10459273/slides/slide_16.jpg © mahesh
  • 6.
    Rules for GoodAlgorithm Input : specified and required input values Output : outcome values or solution of problem Definite : must be defined clearly about what should be done Effective : must be able to perform each step exactly in finite amount of time Finite : finite number of steps Correct : must be able to generate correct and desirable output Algorithm © mahesh
  • 7.
    Algorithm and Flowchart Diagrammaticrepresentation of a program using standard symbols © mahesh
  • 8.
    Flowchart Symbols The basicflowchart symbols © mahesh
  • 9.
    FlowchartTypes System Flowchart Represents thesystem and its components Sequence of instructions to solve specific work Explains the total flow of data inside the system Complex logical structure diagram Program Flowchart  Represents program and its components  Sequence of instructions to solve specific problem  Explains the instructions to solve the problem  Relatively easier logical structure diagram. © mahesh
  • 10.
    Advantages of Flowchart ©mahesh  Easy method to Understand and Communicate  Easier approach than Algorithm and Coding  Applicable to all types of programming languages  Represents all the components of program like input, process, logic and output  Serves as a guide to programmers
  • 11.
    Disadvantages of Flowchart ©mahesh  Cannot replace all types of logics used in computer program  Takes long time to represent all components of computer Program  Not applicable for complex and big types of program or System
  • 12.
    Program Logic orStructure Program consists of different types of logic or structures based on the solution to the identified problems. 3 types of Program Logic or Structures are: i. Sequence : set of instructions which are executed one after another in a steps ii. Selection : set of instructions which are executed conditionally based on conditions that are either true or false iii. Iteration : set of instructions which are executed repeatedly and conditionally by loop conditions © mahesh
  • 13.
    Programming in QBASIC QBASICis the most popular high level programming language. Developed by Microsoft Company, USA. Q => Quick B => Beginners A => All Purpose S => Symbolic I => Instruction C => Code Consists of two basic files QBASIC.EXE and QBASIC.HLP For editing, debugging and executing programs © mahesh
  • 14.
    Structure of QBASIC ©mahesh Structure consists of some of the standard programming elements. They are:  Character Set  Variable and Constants  Arithmetic Expressions  Relational or Logical Expressions  Keywords and Syntax  Library Functions  Conclusion
  • 15.
    Character Set inQBASIC © mahesh Character set in QBASIC consists following standard elements:  Alphabet : (a-z), (A – Z)  Digits : 0, 1, 2, ……….., 9 and  Special Characters : + - * / () . , : ; > < “ ! @ $ etc.
  • 16.
    Variable and Constants ©mahesh Variable and Constants are the memory location of the programming data. However they both are different based on value in computer memory space. i. Constant : Quantity whose value does not change during program execution ii. Variable : Quantity whose value may change during program execution Types of Variable: a. Numeric Constant/Variable b. String Constant/ Variable
  • 17.
    Arithmetic Expressions © mahesh ArithmeticExpressions are the five basic mathematical expressions used in QBASIC. They are: i. Exponentiation (^) ii. Multiplication (*) and Division (/) iii. Addition (+) and Subtraction (-) Follows General BODMAS Rule QBASIC follows the hierarchy according to the mathematical algebraic rules and regulations
  • 18.
    Relational Expressions © mahesh RelationalExpressions are the formed by using following relational operators in QBASIC:
  • 19.
    Logical Expressions © mahesh LogicalExpressions are the formed by using two or more expressions to return value TRUE or FALSE: The common logical operators are: i) AND ii) OR iii) NOT Conjunction Disjunction Logical Negation The result for two expressions A and B using the common logical operators:
  • 20.
    Keywords and Syntax ©mahesh Keywords in QBASIC are the special types of variables that are not applicable to use in computer program. Also called reserved words by QBASIC. For example: INPUT, PRINT, CLS, GOTO, IF, FOR, WHILE, END, ENDIF, LET, etc. Syntax is the set of rules and regulations that must be followed to construct the program in QBASIC programming. Also called Grammar for writing command and statement in developing computer program.
  • 21.
    Library Function © mahesh ‘Library’ stands for collection in general  Library Functions in QBASIC is the set or collection of useful programs and instructions.  Used to simplify the task of programmers.  QBASIC library is rich with mathematical functions like square root, log of number, sine of angle, etc. For example: SQR(), LOG(), SIN(), etc.
  • 22.
    Introduction to QBASICProgramming © mahesh Any Questions
  • 23.