Advertisement
Guest User

Untitled

a guest
Jul 29th, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. static void Main(string[] args)
  2. {
  3. const int SIZE = 50;
  4. int[] array = new int[SIZE];
  5. int index = 0;
  6. int aScore = 0;
  7.  
  8. do
  9. {
  10. Console.WriteLine("Enter a value for the array for position {0} (or 0 to stop):", (index + 1));
  11. aScore = int.Parse(Console.ReadLine());
  12. if(aScore >= 0)
  13. {
  14. array[index++] = aScore;
  15. }
  16. }while (aScore != 0 && index < SIZE);
  17.  
  18.  
  19. Console.WriteLine("The product of the array is: {0}", SumArray(array));
  20. Console.ReadLine();
  21. }
  22.  
  23. static int SumArray(int[] array)
  24. {
  25. int product = 1;
  26. for (int i = 0; i < array.Length; i++)
  27. {
  28. product *= array[i];
  29. }
  30. return product;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement