Programming

Page 1

Programming AGB 111 2013-14

1


Programming- Definition • Series of instructions to a computer to accomplish a task • Instructions must be written in a way the computer can understand • Programming languages are used to write programs

Dr R Jayashree, Asst. Prof Veterinary college, Bangalore

2


Elements of a Program • All programming languages have certain features in common. For example: – Variables – Commands/Syntax (the way commands are structured) – Loops – Decisions – Functions • Each programming language has a different set of rules about these features.

Dr R Jayashree, Asst. Prof Veterinary college, Bangalore

3


Programming languages • Here are some examples of an instruction to print the word HI – Logo

PR [HI]

– JavaScript

alert(“HI”);

– FORTRAN

PRINT “HI”

– BASIC

PRINT “HI”

– COBOL

DISPLAY ‘HI’.

– C++

printf(“HI”);

– Pascal

WRITELN(‘HI’); Dr R Jayashree, Asst. Prof Veterinary college, Bangalore

4


Symbols for programming • START/END • INPUT/OUTPUT • PROCESS • DECISION Dr R Jayashree, Asst. Prof Veterinary college, Bangalore

5


Pseudocode- Flow chart • Task: add two numbers • Pseudocode: – Start – Get two numbers – Add them – Print the answer – End

Start Print answer Get 2 numbers End Add them

Dr R Jayashree, Asst. Prof Veterinary college, Bangalore

6


Calculating Age • Flowchart – Start – Get year born – Calculate age – Print age – If age > 50 print OLD – End

Start

START

Get yr

INPUT

Calc age PROCESS Print ageOUTPUT

OLD

Y

Age>50?

N End

Dr R Jayashree, Asst. Prof Veterinary college, Bangalore

DECISION

END

7


Programme

START

Get 3 grades

• Possible flowchart – Start – Get three grades – Average them – Print Average – Average>80?

Calc avg

Print avg Y

GOOD

• If Yes, print GOOD

– End

Avg>80? N

END Dr R Jayashree, Asst. Prof Veterinary college, Bangalore

8


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.