Homework 1


Due : 9.30am, 6 July

Draw the structure chart for the following program.

void f2 ( int x )
{
   int w = x-1;
   return w;
}

void f3 ( int y )
{
   printf ("%d", y);
}

void f5 ( int z )
{
   printf ("%d", z);
}

int f4 ( int a, int b )
{
   while (a == b)
   {
      f3 (a);
   }
   printf ("%d", f2 (b));
   return 0;
}

int f1 ( int a, int b )
{
   if (a == b)
   {
      f5 (a);
      f3 (b);
      return 0;
   }
   else
      return 1;
}

void main ()
{
   printf ("%d %d", f1(10, 20), f4(30, 40));
}

Solution


Last updated : 6 July 2000 11.11am