Basic programming

download Basic programming

of 25

  • date post

    15-Jul-2015
  • Category

    Education

  • view

    83
  • download

    1

Embed Size (px)

Transcript of Basic programming

BASIC PROGRAMMING

Submitted by:Nicole Danielle MallariKeith Alison ArellanoBASIC PROGRAMMINGIntroductionImportance of computersWhat is a computer?Computer ProgramsProgramming Languages

What Computers Can DoArithmetic OperationsComparison (logical) operationsStorage & retrieval operationsSpeed & AccuracyComponents of a Computer SystemHardwareSystem UnitCPU control unit & arithmetic logic unitMain MemoryPeripheral DevicesInputOutputComponents of a Computer SystemSecondary StorageFloppy disk, hard drive, CD, DVD, Flash DriveSecondary Storage DevicesUsed to copy data to & from secondary storageStorage space measured in BytesKilobyte, Megabyte, Gigabyte, Terabyte

Categories of Computer SystemsSupercomputersMainframesMinicomputersMicrocomputersWhere Did All this Start?Operating SystemUser InterfaceCommand-Line InterfaceGraphical User InterfaceDOS Disk Operating SystemCommand-lineUsed to run QBasicQBasicDesigned from the BASIC languageEnhanced, menu-drivenOnline HelpStructured language Running QBasicInstalled on your H: driveDouble click on QB.exeUse mouse and arrow keys to navigateMenu BarFile- EditView- SearchRun- DebugOptions- HelpQBasicTitle BarReference BarImmediate Window

Demonstration

MenusFileNewOpenSaveSave AsPrintExitMenusViewSUBsSplitOutput ScreenRunStartRestartContinue

Entering & Editing ProgramsUse CLS to clear screen at beginningType commands one line at a timeHit Enter to go to next lineScroll up & down as neededKey Words in QBasicCLS INPUTPRINTPut text in double quotesUse semi-colon ; between quoted text & variable namesUse $ for text variablesUser$, Instructor$, Title$

Being a Responsible Computer UserComputer EthicsHardwareBackup dataStore media properlySoftwareCommercial SoftwareSharewarePublic-domain SoftwareThere are also special functions called commands (also called instructions). A command tells that the Qbasic interpreter to do something.The PRINT command tells the Qbasic interpreter to print something to the screen. In this case, the interpreter printed Hello World ! .CommandsTIP: Instead of typing PRINT, you can enter a question mark. For example:

?Hello World!With the PRINT command, you can also print numbers to the screen. Delete the current program (unless you already have) and write the following:

PRINT 512 (or ?512)Press F5 to run the program, the program outputs:512

An expression is something the interpreter calculates (or evaluates). Such us:

1 + 1(returns 2)100 47(returns 53)3 * 34(returns 102)80 / 4(returns 20)(100 * 3) + (returns 356)ExpressionsCLSAn abbreviation that stands for the words Clear Screen . In the above program, when you used CLS on line 60, all the words that were printed to the screen were wiped away.PRINTWrites the screen. There are commands to other things like printer, but thats to be discussed later. Each new Print command will start printing on a new line. To insert a blank line, dont specify a string to print. The syntax for PRINT is PRINT [whatever you want to be here]ENDIt stops the program at that line; that is, anything thats added after that wont show. Thats why the PRINT command on line 90 didnt print anything. The END command can be included in control structures to end the program if a condition is met. This will be discussed with control structures.

Given the state of computer speed today you should not see the paragraph displayed by lines 20 through 50, it should be cleared by the CLS statement on Line 60 before you have a chance to see it.

An operator is a code element that performs an operation on one or more code elements that hold values. Value elements include variables, constants, literals, properties, returns from function and operator procedures and expressions.An expression is a series of value elements combined with operators which yields a new value. The operators act on the value elements by performing calculations, comparisons or other operations.Operators and Expressions in Visual Basic.Visual Basic provides the following types of operators:Arithmetic Operators perform familiar calculations on numeric values, including shifting their bit patterns.Comparison Operators Compare two expressions and return a boolean value representing the result of the comparison.Concatenation operators join multiple strings into single string.Logical and Bitwise Operators in Visual Basic combine Boolean or numeric values and return a result of the same data type as the values.Types of Operators