programming getting started
Download
Skip this Video
Download Presentation
Programming Getting started

Loading in 2 Seconds...

play fullscreen
1 / 26

Programming Getting started - PowerPoint PPT Presentation


  • 106 Views
  • Uploaded on

Programming Getting started. A computer program is a set of statements or instructions to be used directly or indirectly in a computer in order to bring about a certain result There are many languages that can be used to program a computer.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Programming Getting started' - len


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
programming getting started
ProgrammingGetting started
  • A computer program is a set of statements or instructions to be used directly or indirectly in a computer in order to bring about a certain result
  • There are many languages that can be used to program a computer.
    • Machine language (program written for one type of computers)
    • High-level language (general-purpose language, compatible with human language)
slide2
There are three basic steps
  • A set of information, called the input data, is entered into the computer and stored.
  • The input data is then processed to produce certain desired results, known as the output data.
  • The output data are printed or displayed or saved on the computer.
slide3
Example: write the required steps to calculate the area of a circle using πr2, given a numerical value for the radius r as input data
  • Read the numerical value for the radius of the circle
  • Calculate the value of the area using the given formula.
  • Print (display) the values of the radius and the corresponding area.
  • Stop
what you need to know is
What you need to know is:
  • Reading input…….
  • Displaying output …..
  • Processing data (Branching, looping, functions, subroutines….)
  • Processing a program
operators
Operators

+ Addition

- Subtraction

* Multiplication

/ Division

slide9
\' {$STAMP BS2}

\' {$PBASIC 2.5}

x VAR Byte

x=65

DEBUG "hello",CR

\'DEBUG ? x

\'DEBUG DEC x, CR

\'DEBUG IBIN x,CR

\'DEBUG IHEX x, CR

END

Run

write a simple program to calculate the area and the perimeter of a 8x 4 rectangle
Write a simple program to calculate the area and the perimeter of a 8x 4 rectangle
  • Read the numerical value for the length and the width of the rectangle
  • Calculate the value of the area using the given formula.
  • Print (display) the values of the radius and the corresponding area.
  • Stop
slide11

Start

Read l & W

Calculate

Area and Perimeter

Print area and perimeter

Stop

slide12
length CON 8

width CON 4

area CON length*width

perimeter CON length+width* 2

DEBUG CR, “area= “

BEBUG DEC area

DEBUG CR, “perimeter= “

Debug DEC perimeter

END

looping
Looping
  • Looping involves repeating some portion of the program either a specified number of times or until some particular condition has been satisfied
  • Do loop
  • For Next
  • Goto
slide14
DO- LOOP: let a program execute a series of instructions indefinitely or until a specific condition terminates the loop.

DO

DEBUG “Hello”, CR

Loop

slide15
DO-WHILE

The program will not run if the condition is not satisfied.

Length=15

Height=4

DO WHILE (height<10)

area=length*height

height= height+1

loop

slide16
\' {$STAMP BS2}

\' {$PBASIC 2.5}

length CON 15

height VAR Byte

height=4

area VAR Word

DO WHILE (height<10)

area=length*height

height=hight+1

LOOP

DEBUG DEC area

slide17
DO-UNTIL

The program will run until the condition is satisfied.

Length=15

Height=4

DO

area=length*height

height= height+1

Loop until (height=10)

slide18
\' {$STAMP BS2}

\' {$PBASIC 2.5}

length CON 15

height VAR Byte

height=4

area VAR Word

DO

area=length*height

height=hight+1

DEBUG DEC area

Loop Until (height=10)

slide19
FOR-NEXT

Execute the statements between FOR and NEXT until the value of the counter passes the end value

For height=6 to 10

Length=10

area=length*height

Next

slide20
\' {$STAMP BS2}

\' {$PBASIC 2.5}

length CON 15

height VAR Byte

area VAR Word

FOR height =6 TO 10

area=length*height

DEBUG DEC area, CR

NEXT

slide21

Start

DO

Read r

Calculate

a

Print a and r

loop

Yes

NO

Stop

if then
IF-THEN
  • IF condition is trueTHEN(execute the following statement (s))

IF x<20 Then

area =x*y

  • IFcondition is trueTHEN

(execute the following statement (s))

ELSE

(execute the following statement (s))

slide23
IFcondition is trueTHEN

(execute the following statement (s))

ELSEIF condition is trueTHEN

execute the following statement (s))

ENDIF

subroutines
Subroutines
  • To avoid repeated programming of the same calculations
  • Subroutines can be referenced (called) from other places in the program
  • GOSUB is used to redirect the program to the subroutine
  • RETURN causes the program to jump back to the line of code that follows the calling GOSUB
example
Example

Main:

GOSUB Hello

GOSUB Goodbye

Hello:

DEBUG ”Hello There”, CR

RETURN

Goodbye:

DEBUG “Bye now”, CR

RETURN

ascii code
ASCII Code
  • ASCII is acronym for the for American Standard Code for Information Interchange (Pronounced ask-ee ).
  • ASCII is a code for representing English characters as numbers, with each letter assigned a number from 0 to 127.
  • For example, the ASCII code for uppercaseM is 77.
  • Most computers use ASCII codes to represent text, which makes it possible to transfer data from one computer to another.
ad