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.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes