Lecture_Notes_02

Lecture_Notes_02 - Errors Syntax Errors detected at compile...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
25 Errors • Syntax Errors – detected at compile time • Logical Errors – detected at run time • Warnings – detected at compile time
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
26 Syntax Errors OR Compile Time Errors • Usually a result of typo • Good compilers tell you what you did wrong and where you made mistake #include <cstdlib> #include <iostream> using namespace std; int Main() { cout<< "Hello World" ; system( "PAUSE" ) return EXIT_SUCCESS;
Background image of page 2
27 Logical Errors OR Run Time Errors When the program is syntactically correct, and does something, but it does n‟t do what it is supposed to do Hard to detect #include <cstdlib> #include <iostream> using namespace std; int main() { cout<< "Helllo World" ; system( "PAUSE" ); return EXIT_SUCCESS; }
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
29 Variables Variable Declaration: Variable-type variable-name = initial value ; What type of data is stored? What it is known by in the program Starting value optional, but generally a good idea int r = 3 ; float pi = 3.14 ;
Background image of page 4
30 How the variables are stored in memory? int r = 3 ; In binary format: 00000000 00000000 00000000 00000011 Each cubbyhole represents 1 byte
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
31 Data Types Integers are represented by: Type Size Value short or short int 2 bytes -32,768 to 32,767 int (16 bit) 2 bytes -32,768 to 32,767 int (32 bit) 4 bytes -2,147,483,648 to 2,147,483,647 long or long int 4 bytes -2,147,483,648 to 2,147,483,647 size of short <= size of int <= size of long In general, range can be calculated by the formula: -2 n-1 to 2 n-1 -1 where n is the number of bits
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/01/2012 for the course GENE 121 taught by Professor Smucker during the Winter '11 term at Waterloo.

Page1 / 21

Lecture_Notes_02 - Errors Syntax Errors detected at compile...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online