Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Trial
- {
- class Eldest
- {
- public static void Main()
- {
- int i, eldest;
- int[] array = new int[5];
- for (i = 0; i < 5; i++)
- {
- Console.WriteLine("enter elements: {0}", i + 1);
- array[i] = Convert.ToInt32(Console.ReadLine());
- }
- eldest = array[0];
- for (i = 1; i < 5; i++) //start from 1 as you are already considering 0th as max
- {
- if (array[i] > eldest)
- {
- eldest = array[i];
- }
- }
- Console.WriteLine("the eldest number is {0}", eldest);
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement