Puzzle SL17


#include <stdio.h>

int dum( int x )
{
  x -= 1 ;
  x = dee(x);
  return x;
}

int dee( int a )
{
  if ( a > 10 )
    a = dum(a);
  else
    a -= 2 ;

  return a;
}

int main ( void )
{
  int x;
  
  x = dum(7);
  printf("scope m: x=%d\n", x);

  return 0 ;
}

Question 1: Will the program compile and run?

Question 2: Will it produce the correct result?

Question 3: Fix or improve the program.

Recall the following rule: If an identifer that has not been previously declared occurs in a program and is followed by a '(' , then the identifier is implicitly declared to be a function returning int. Nothing is assumed about the parameters of the function.



Previous Page        Answer         Next Page         Home