Arrays-Aeronautical Engineering And Computer Programming-Lecture Slides, Slides of Aeronautical Engineering

Prof. Balamohan Pawar delivered this lecture at Allahabad University for Aeronautical Engineering and Computer Programming course. Its main points are: Array, Loops, Element, Dimension, Array, Design, Declare, Text, Display, Length

Typology: Slides

2011/2012

Uploaded on 07/20/2012

savitha_48
savitha_48 🇮🇳

3

(1)

109 documents

1 / 11

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Arrays
1, i2,..,in)
elements.
for I in 1 loop
;
for I in 1 loop
for J in 1 .. N loop
Put (B(I,J));
end loop;
end loop;
Records
design a record
declare record types and variables
use a record
Access elements using Indices
– Single Dimension arrays A(I)
– Two dimensional arrays A(I,J)
– N dimensional array A(i
Loops can be used to access control to
.. N
Get (A(I));
end loop
.. M
To use records we need to know:
1. How to
2. How to
3. How to
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Arrays-Aeronautical Engineering And Computer Programming-Lecture Slides and more Slides Aeronautical Engineering in PDF only on Docsity!

Arrays

1 , i^2 ,..,in)

elements.

for I in 1 loop

for I in 1 loop for J in 1 .. N loop Put (B(I,J)); end loop; end loop;

Records

design a record

declare record types and variables

use a record

• Access elements using Indices

  • Single Dimension arrays A(I)
  • Two dimensional arrays A(I,J)
  • N dimensional array A(i

• Loops can be used to access control to

.. N

Get (A(I));

end loop

.. M

To use records we need to know:

  1. How to
  2. How to
  3. How to

1. Designing Records

  • identify the items of data that are relevant

data structure diagram to show the relevant information names for the overall structure, and for the individual fields

data types of the fields

Example1 Fitness club

name : names;

phone : phones;

sex : sexes;

age : ages;

weight : weights;

name phone sex age weight

persons

• To design a record:

in this application

  • use a
    • decide on
  • determine the

-- string sub-type

-- string sub-type

-- enumerated type

-- integer sub-range

-- float sub-type

3. Using records

assignment, parameter, comparison,

etc) just use its name

record_name.field_name

  • average_male.weight average_female.name

3. Using records

another of identical type

a single operation. You must read each field separately.

• To refer to an entire record variable (for

• To refer to a field of a record, use

• Assignment

  • You can assign one record variable to
    • that_person := this_person;

• Input

  • You cannot read an entire record variable in
  • To input a record variable use a procedure:
    • Prompt for and get each field in turn

CQ 1

My_Second_Record

3. Using records

in a single operation. You must display each field separately.

procedure:

1. My_First_Record contains contents of

2. Program will not compile

3. Program gives a run-time error

4. Don’t know

• Output

  • You cannot display an entire record variable
  • To display a record variable use a
    • Describe and display each field in turn

Hierarchical records

any

type, including another record

phone weight

age sex

persons

name title

fname

sname

text_io

line?

• The components of a record can be

• Text_IO

  • Page line character
    • set_col : go to nominated column in output file
    • new_line: go to next line of output
    • set_line: go to nominated line in output file
    • new_page: go to next page of output
    • skip_line: go to start of next line in input
    • skip_page: go to start of next page of inputs
    • page: what page number are we up to in the file?
    • line: what line number are we up to on the page?
    • col: what character position are we up to on the

example

SET_COL (30);

PUT ("Student Results Report"); SET_LINE (4); SET_COL ( 5); PUT ("Student name"); SET_COL (35); PUT ("Assignments"); SET_COL (50); PUT ("Exams"); SET_COL (65); PUT ("Average"); SET_LINE (6);

Line length

reached

– SET_LINE_LENGTH (30);

for i in 1 .. 20 loop PUT (i**2, width => 5); ; (^) ' 1 4 9 16 25 36' ‘ 49 64 81 100 121 144' ' 169 196 225 256 289 324' ' 361 400'

• SET_LINE (2);

• For output files

  • set_line_length for lines
  • set_page_length for pages

• set_line_length

  • EOL generated automatically when limit
  • Default is 0

end loop

reset

procedure:

open (filevar, in_file, filename); --code to read from the file reset (filevar); --code to read the file all over again close (filevar);

File position functions

• if END_OF_PAGE (infile) then …

while not END_OF_FILE loop …

Need to process a file twice. RESET

Go back to beginning (optionally) change mode File must be open already

-- read file twice

• END_OF_FILE

  • Next character is EOF
  • Next character is combination of EOL, EOP, EOF

• END_OF_LINE

  • Next character is EOL or EOF

• END_OF_PAGE

  • Next character is combination of EOL and EOP
  • Next character is EOF

Example2 Priority Queue

done efficiently.

Q 5 -3 0 5 12 17?????

0 1 2 3 4 5 6 7 … N

Q

• Data structure that stores items so that

retrieval of ‘highest priority’ item can be

• Highest priority have lower values

• Operations: PUT, GET, EMPTY

Free