Download
c programming chapters 11 n.
Skip this Video
Loading SlideShow in 5 Seconds..
C Programming Chapters 11, . . . PowerPoint Presentation
Download Presentation
C Programming Chapters 11, . . .

C Programming Chapters 11, . . .

209 Vues Download Presentation
Télécharger la présentation

C Programming Chapters 11, . . .

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. C ProgrammingChapters 11, . . . • C – Compiler Compilation • Tracing C programs • C Functions • C program Stack Structure

  2. Memory map (Global Data pointer) I/O Devices

  3. C Functions All C programs begin with the main Function: #include <stdio.h> ; include libraries for compiler #define Two = 2 ; “Two” will be replaced in code with 2 int x = 56; ; x is a global variable int main () ; main has an “int” type return value { int y = 47; ; y is a local variable return 0; ; return the value “0” }

  4. C Functions #include <stdio.h> int sum (int r, int s, int t); int main() { z = sum (x,y,z) + 65; } int sum (int A, int B, int C) { int total; ; total is a local variable total = A + B + C); return total; ; return the sum }

  5. C Program int Func1(int x) { return Func2(x) + 1; } int Func2(int x) { return Func3(x) + 1; } int Func3(int x) { return Func4(x) + 1; } int Func4(int x) { return x + 1; } #include <stdio.h> int Func1(int x); int Func2(int x); int Func3(int x); int Func4(int x); int main() { int A = 3; int B = 5; int C; C = A + B; C = Func1(C); C = C + 1; return 2; }

  6. C Program Compilation • Compile the program • Look at the files • Load them into the LC-3 simulator • Execute the program and observe its stack