/* File: p5test1.c The program checks that scoping rules are followed. Ths program also checcks on parameter passing. */ #include typedef int bool ; int a, b, c ; void proc1 (int a, int n) { int b ; printf("In procedure 'proc1'\n") ; b = a * a + n ; printf("a = %d\n", a ) ; printf("b = %d\n", b ) ; printf("c = %d\n", c ) ; printf("n = %d\n", n ) ; /* This should be allowed but have no affect in the caller */ a = 17 + c ; b = 203 - a ; printf("a = %d\n", a ) ; printf("b = %d\n", b ) ; printf("c = %d\n", c ) ; printf("n = %d\n", n ) ; printf("Exiting procedure 'proc1'\n") ; return ; } void proc2 (int a, int b, float x, float y, bool p) { if (p && a < b) { printf("The answer is %lf\n", x - y) ; } else { printf("The real answer is %lf\n", (y * y)/x ) ; } } main() { int b, x ; a = 9999 ; b = 888 ; c = 77 ; x = a * b -c ; printf("In proceudre main, before call to proc1()\n") ; printf("a = %d\n", a ) ; printf("b = %d\n", b ) ; printf("c = %d\n", c ) ; printf("x = %d\n", x ) ; proc1(a, x) ; printf("a = %d\n", a ) ; printf("b = %d\n", b ) ; printf("c = %d\n", c ) ; printf("x = %d\n", x ) ; printf("In proceudre main, after call to proc1()\n") ; proc2(a, c, 2.317, 668.214513, 1) ; }