topical media & game development

talk show tell print

basic-program-solutions-04-Soln4-5.c

? / basic-program-solutions-04-Soln4-5.c


  // Soln4_5.cpp : main project file.
  
  include <stdafx.h>
  
  using namespace System;
  
  int main(array<System::String ^> ^args)
  {
    Random^ generator = gcnew Random;
    int number = generator->Next(0,Int32::MaxValue-10000) + 10000;
    Console::WriteLine(L"The value is {0}", number);
  
    array<String^>^ digitWord = {L" zero", L" one", L" two", L" three", L" four",
                             L" five", L" six", L" seven", L" eight", L" nine"};
    String^ inWords = L"";
  
    while(number > 0)
    {
      inWords = digitWord[number % 10]+inWords;
      number /= 10;
    }
    Console::WriteLine(inWords);
    return 0;
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.