computer programming

20
Computer Programming Program Concepts Introduction An to

Upload: leigh-ann-garrote

Post on 28-Jul-2015

128 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Computer programming

Computer Programming

Program Concepts

Introduction

An

to

Page 2: Computer programming

This lecture contains… Computer programsQbasic

- Features - Rules - Parts - Qbasic Editor screen Commands/ Keywords and their

functionsDevelopment cycleProgram Planning

Page 3: Computer programming

Programming Language

In computer technology, It is a set of conventions in which instructions for the machine are written. There are many languages that allow humans to communicate with computers; C++, BASIC, and Java are some common ones.

Page 4: Computer programming

Basic Cobol C, C++

Fortran Pascal ADA JAVA HTML

According to Sammet, over 200 programming languages were developed between1952 and 1972, but she considered only about 13 of them to be significant

>> Main Programming Languages

Page 5: Computer programming

What is QBasic?QBASIC is a stripped-down version of QuickBasic that Microsoft released in 1991, which was included for free with MS-DOS 5 and later versions. It also comes packed-in with the Windows 95 and Windows 98 operating systems.

QBASIC is shareware. The latest version is Version 1.1.

Page 6: Computer programming

About Qbasic… BASIC stands for Beginner’s All Purpose Symbolic Instruction Code. It was invented in 1963, at Dartmouth College, by the mathematicians John George Kemeny and Tom Kurtzas.

BASIC is an interpreter which means it read every line, translates it and lets the computer execute it before reading another. Each instruction starts with a line number.

Page 7: Computer programming

FEATURES OF QBASIC

It is a user friendly language. It is widely known and accepted

programming language. It is one of the most flexible

languages, such as modification can easily be done in already existing program.

Language is easy since the variables can be named easily and uses simple English phrases with mathematical expressions.

QBASIC automatically checks syntax. QBASIC capitalizes the reserved words.

Page 8: Computer programming

Rules Of QBasic

• 1) All QBasic programs are made up of series of

statements, which are executed in order in which they are

written.

• 2) Every statement should have at least one QBasic

command word. The words that BASIC recognizes are

called keywords.

• 3) All the command words have to be written using some

standard rules, which are called “Syntax Rules”. Syntax is

the grammar of writing the statement in a language.

Syntax Errors are generated when improper syntax is

detected.

Every programming language has a set of rules that have to e followed while writing a program, following are some rules of QBASIC LANGUAGE.

Page 9: Computer programming

The Qbasic Editor Screen

QBASIC editor is the window where you write programs. The editor provides all the facilities to write programs and editing them.

Page 10: Computer programming

• MENU BAR.— NAMES EACH MENU. WHEN YOU PRESS THE ALTT KEY, THE HIGHLIGHTED LETTER INDICATES WHICH KEY "PULLS DOWN" THAT MENU. VIEW WINDOW.— DISPLAYS YOUR PROGRAM'S TEXT. CURSOR.— SHOWS WHERE THE TEXT YOU TYPE WILL APPEAR. THE CURSOR APPEARS IN THE ACTIVE WINDOW. MOUSE CURSOR.— SHOWS CURRENT ON-SCREEN POSITION OF MOUSE (USE WITH MOUSE ONLY).

TITLE BAR.— SHOWS THE NAME OF THE PROGRAM OR PROCEDURE. MAXIMIZE BOX.— EXPANDS THE ACTIVE WINDOW TO FILL THE SCREEN (USE WITH MOUSE ONLY). SCROLL ARROW.— SCROLLS THE TEXT ONE CHARACTER OR ONE LINE AT A TIME (USE WITH MOUSE ONLY). SCROLL BOX.— SHOWS CURSOR'S RELATIVE POSITION WITHIN THE FILE OR PROCEDURE.

Menu Bar

View Windo

w

Mouse

Cursor

Cursor

Title Bar

Maximize Box

Scroll Arrow

Scroll Box

Parts

Page 11: Computer programming

BOTTOM HALF OF QBASIC INVOCATION SCREEN 

IMMEDIATE WINDOW.— • EXECUTES QBASIC STATEMENTS DIRECTLY; THEY NEED NOT BE ENTERED AS PART OF A PROGRAM.

CAPS LOCK AND NUM LOCK INDICATORS.— • C APPEARS WHEN THE CAPS LOCK KEY IS TOGGLED ON. NAPPEARS WHEN THE NUM LOCK KEY IS

TOGGLED ON. SCROLL BARS.—

• SCROLLS TEXT IN THE CURRENTLY ACTIVE WINDOW (USE WITH MOUSE ONLY).

REFERENCE BAR.— • CONTAINS REFERENCE INFORMATION. THE FIRST FIVE ITEMS ARE BUTTONS SHOWING A

FREQUENTLY USED SHORTCUT KEY AND THE CORRESPONDING MENU OR OPTION. CLICKING A BUTTON WITH THE MOUSE GIVES THE SAME RESULT AS PRESSING THE SHORTCUT KEY SHOWN IN

THE BUTTON. PRESSING ALT DISPLAYS FOUR DIFFERENT REFERENCE ITEMS.

WORDSTAR-STYLE COMMAND INDICATOR.— • ^Q APPEARS WHEN YOU ENTER CTRL+Q, A WORDSTAR-STYLE COMMAND. ^K APPEARS HERE WHEN

YOU ARE SETTING A PLACE MARKER (SEE SECTION 12.4, "USING PLACEMARKERS IN TEXT"). ^P APPEARS HERE WHEN YOU ARE ENTERING A LITERAL CHARACTER (SEE SECTION 12.6 , "ENTERING

SPECIAL CHARACTERS").

Page 12: Computer programming

Run

It is possible to overwrite lines with the new statements, but if you want to write a totally new program use a NEW command.

Exiting QBasic In order to exit the QBASIC program SYSTEM command is used.

• is the command used to execute the program and get the output on the screen.

Page 13: Computer programming

COMMAND/KEYWORDS IN QBASIC AND THEIR FUNCTIONS:

List-Used to list the

program on the screen

RUN-Used to execute the program

LList-Used to list the

program as a

hardcopy

LPrint-Used to get the

output of the

program on the

hardcopy

New-Used

to clear the

memory of the existing program

System-Used to take

you back to

dos prompt

Save-Used

to save the

program

Load-Used

to load the

program from the disk to the

memory

Page 14: Computer programming

Commands

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 555 (or ?555)<press Enter>Press F5 to run the program. The program outputs:555

There are also special functions

called “commands” (also called

“instructions”). A “command” tells

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!”.

TIP: Instead of typing PRINT you can enter a question

mark. For example:

?“Hello World!”

Page 15: Computer programming

Menus

• access to drop down menus by:– using mouse– pressing ALT key highlights shortcut keys

e.g. F, E, V etc. to menus; highlighted letters in menu are shortcuts

• ESC key to return to View Screen

ALT + enter to maximise screenCtrl + break to stop a continuously looping program

Important keys

Page 16: Computer programming

determine outputs - what is the question?

determine inputs - what is the user required to enter/ data available?

determine process - algorithm / mathematical formulasInput Process OutputAlgorithm

- step by step solution to the

problem

Page 17: Computer programming

Steps in Planning the program

Analysis - define the program Design - plan the solution; consider

all ‘what if scenarios’ Code - translate into (QBasic)

language Test and Debug DOCUMENTATION!!!!!

Programming

Tools

• Flowcharts• Pseudocode• Top-down • charts

Page 18: Computer programming

Flow charts

• represents the steps in the algorithm in a graphical manner

start

Pay rate = 6.25

Hours = 25

Gross pay = Pay rate * hours

Print Gross Pay

End

Page 20: Computer programming

A Presentation By:

Leigh-ann Garrote

Aileen Jeanne Gumop-as

All Rights reserved 2015

#78 Brgy. Santiago, Binalonan Pangasinan

#05 Brgy. Sta. Catalina, Binalonan Pangasinan