What will be printed out as a result of the following code execution:
 
class Test 
{ 
    static void Main(string[] args) 
    { 
          char[] vowels = {'a','e','i','o','u'};
          for (int i = 1; i <= vowels.Length; i++)         
          Console.Write(vowels[i] + " "); 
      } 
}
 
Explanation
Array indices start from 0. The following cycle should be used to iterate over all array elements:
 for (int i = 0; i < vowels.Length; i++) 
(strictly less).
IndexOutOfRangeException will occur in the mentioned case.

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести