Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Trial
  8. {
  9. class Eldest
  10. {
  11. public static void Main()
  12. {
  13. int i, eldest;
  14. int[] array = new int[5];
  15. for (i = 0; i < 5; i++)
  16. {
  17. Console.WriteLine("enter elements: {0}", i + 1);
  18. array[i] = Convert.ToInt32(Console.ReadLine());
  19. }
  20. eldest = array[0];
  21. for (i = 1; i < 5; i++) //start from 1 as you are already considering 0th as max
  22. {
  23. if (array[i] > eldest)
  24. {
  25. eldest = array[i];
  26. }
  27. }
  28. Console.WriteLine("the eldest number is {0}", eldest);
  29. Console.ReadLine();
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement