UMBC CS 201, Fall 98
UMBC CMSC 201 & 201H Fall '98 CSEE | 201 | 201 F'98 | lectures | news | help

Tracing Programs

The Task

trace

The Program

/*************************************************\ * trace.c * * This program illustrates local variables and is * * to be used to demonstrate the techniques of * * tracing a program by hand. * \*************************************************/ #include <stdio.h> int Foobar (int a); int Geez (int b); main () { int a = 1, b = 2, c = 3; c = Geez (a); b = Foobar(c); printf("main: a = %d, b = %d, c = %d\n", a, b, c) ; } /* Foobar is used to illustrate tracing code */ int Foobar (int b) { int a, c; a = Geez (b); c = b++; printf("Foobar: a = %d, b = %d, c = %d\n", a, b, c); return (c); } /* Geez is used to illustrate tracing code */ int Geez (int c) { int a, b; a = c + 100; b = 2 * a; printf("Geez: a = %d, b = %d, c = %d\n", a, b, c); return (a); }

The Sample Run

Geez: a = 101, b = 202, c = 1 Geez: a = 201, b = 402, c = 101 Foobar: a = 201, b = 102, c = 101 main: a = 1, b = 101, c = 101


CSEE | 201 | 201 F'98 | lectures | news | help

Tuesday, 22-Sep-1998 17:03:33 EDT