topical media & game development

talk show tell print

basic-program-solutions-03-Soln3-5.c

? / basic-program-solutions-03-Soln3-5.c


  // Soln3_5.cpp : main project file.
  
  include <stdafx.h>
  
  using namespace System;
  
  int main(array<System::String ^> ^args)
  {
     wchar_t ch;
     int nVowels=0, nChars=0;
  
     Console::WriteLine(L"Enter characters and enter 'Q' or 'q' to end:");
     for (;;)
     {
        ch = Console::ReadKey().KeyChar;
  
        if (ch == 'q' || ch == 'Q')
           break;
  
        switch(Char::ToLower(ch))
        {
        case 'a': case 'e': case 'i': case 'o': case 'u':
           nVowels++;
  
        default:
           nChars++;
        }
     }
  
     Console::WriteLine(L"\nTotal chars={0}, vowels={1}", nChars, nVowels);
    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.