
// illustration of variable-number-of-arguments subroutines for homework

int X = 3, Y = 4, Z = 5, U = 13, V = 12;

int OurMax()  // notice there are no arguments declared

{  int NArgs,  // number of arguments founds by GetNumArgs()
       MaxSoFar,  // has the max of all arguments viewed so far
       Tmp,I;

   NArgs = GetNumArgs();
   MaxSoFar = GetArg(0);  // get the first ("0th") argument
   for (I = 1; I < NArgs; I++)  {
      Tmp = GetArg(I);
      if (Tmp > MaxSoFar) MaxSoFar = Tmp; 
   }
   return MaxSoFar;
}

main()

{  printf("%d\n",OurMax(X,Y,-1));  // prints 4
   printf("%d\n",OurMax(U,V,Z,-1));  // prints 13
   printf("%d\n",OurMax(Z,X,V,Y,-1));  // prints 12
}


