CCSB163 Final - Mar 2007.pdf - MetaLab - Universiti Tenaga Nasional
CCSB163 Final - Mar 2007.pdf - MetaLab - Universiti Tenaga Nasional
CCSB163 Final - Mar 2007.pdf - MetaLab - Universiti Tenaga Nasional
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
(c)<br />
(d)<br />
Briefly describe the difference between local variable with and without<br />
STATIC storage.<br />
[2 marks]<br />
Trace and write the output for the program below:<br />
#include <br />
int m=12;<br />
int f(int a,int b,int c);<br />
void main(void)<br />
{<br />
int n=30;<br />
int x=1,y=2,z=3,i;<br />
printf("Before: m=%d, n=%d, x=%d\n",m,n,x);<br />
i=f(x,y,z);<br />
}<br />
printf("After: m=%d, n=%d, x=%d\n", m,n,x);<br />
int f(int a,int b,int c)<br />
{<br />
int n=100;<br />
printf("In function f: n=%d, m=%d, a=%d\n",n,m,a);<br />
m=999;<br />
if (a >=1)<br />
{<br />
a+=b+m+n;<br />
printf("modified: n=%d, m=%d, a=%d\n",n,m,a);<br />
}<br />
}<br />
return a;<br />
[6 marks]<br />
Semester 2 2006/2007<br />
Page 9 of 11<br />
Principles of Programming