Variables and Arrays

0.0(0)
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/7

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

8 Terms

1
New cards

Basic Types

  • integer/rational

  • range of values

  • signed/unsigned

  • precision

2
New cards

Literals

often need ‘type conversion’

<p>often need ‘type conversion’</p>
3
New cards

Converting Floating Point to Integer

truncate the decimal point DON’T ROUND

4
New cards

Scopes

variables need to be in the right scope to be visible where they are needed

5
New cards

Local Scope

created when it’s declared and automatically destroyed when the function containing it ends

6
New cards

Global Scope

visible to the whole file

try not to use ad they take up too much memory

7
New cards

Variable Rules

  • must be declared before use

  • generally declared ‘close’ to where you need to use them

  • should be initialised with some value before use

    • if you don’t you will be given a random number, different every time the program is run

8
New cards

Accessing Data at other Scopes

  • don’t use global variables

  • pass data using using parameters to functions

  • return results using ‘return’ so functions evaluate to something

    • often assign the result of a function call into a variable to use later