Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Programming

Similar presentations


Presentation on theme: "Introduction to Programming"— Presentation transcript:

1 Introduction to Programming
Engineering 1020 Introduction to Programming Peter King Winter 2010

2 ENGI 1020: Variables Functions have two main components
Data – blocks of information Numbers, letters Instructions – task to be completed on the data Mathematical, logical, display Takes data and generates new data Variables are the means we use to store data

3 ENGI 1020: Variables Variables offer a place to hold data
Data in a variable can change You might say they're variable Variables can hold data from a specified set of values (its type) Variables must be declared before they can be used

4 ENGI 1020: Variables Type Variables are like bins for storing data
Different data goes in different bins Big data, big bins Small data, small bins Int … -3, -2, -1, 0, 1, 2, 3, ..... Computer places limit on max/min Long Same as int, but longer (bigger bin)

5 ENGI 1020: Variables Float Double Char -3.2111, 0.198734, 5.6, 7.0
Real numbers Computer places limit on max/min Double Sames as float, but double the precision More decimal places Limited by computer Char All symbols that can be printed to screen Letter, numbers, punctuation Special chars (\n, \t)

6 ENGI 1020: Variables CHAR_BIT Number of bits for a char object (byte) 8 INT_MIN Minimum value for an object of type int INT_MAX Maximum value for an object of type int UINT_MAX Maximum value for an object of type unsigned int LONG_MIN Minimum value for an object of type long int LONG_MAX Maximum value for an object of type long int ULONG_MAX Maximum value for an object of type unsigned long int

7 ENGI 1020: Variables Variables have 4 attributes Name Address Type
Given by the human Address Assigned by the compiler Type Chosen by the human Value Set by human, computer, function, expression, etc. The power of variables is that the value changes, but the name, type, address stay the same

8 ENGI 1020: Variables We must declare variables before use
Type name = expression The type is chosen for the particular application The name follows the rules and makes sense The expression sets the initial value Not required, but a good idea. The computer will assign a new variable an address The compiler keeps track of what address the variable points to char c; int x = 0; double y = ;

9 ENGI 1020: Variables bins

10 ENGI 1020: Variables Examples from online notes


Download ppt "Introduction to Programming"

Similar presentations


Ads by Google