Mngaro Mwazenje

Mngaro Mwazenje

  • NA
  • 80
  • 13.1k

print array stars

Mar 7 2020 3:31 AM
Complete the method public static void PrintArrayInStars(int[] array) in the template to make it print a row of stars for each number in the array. The amount of stars on each row is defined by the corresponding number in the array.
 
You can try out the printing with this example:
 
int[] array = {5, 1, 3, 4, 2}; PrintArrayInStars(array);
  1. using System;  
  2. using System.Collections.Generic;  
  3.   
  4. namespace exercise_82  
  5. {  
  6. class Program  
  7. {  
  8. public static void Main(string[] args)  
  9. {  
  10. // You can test your method here  
  11. int[] array = { 5, 1, 3, 4, 2 };  
  12. PrintArrayInStars(array);  
  13. }  
  14.   
  15. public static void PrintArrayInStars(int[] array)  
  16. {  
  17. int i = 0;  
  18. while (i < array)  
  19. {  
  20. Console.Write("*");  
  21. i++;  
  22. }  
  23. }  
  24. }  
  25. }

Answers (1)