The task is to find the largest element of an array in Golang by taking input values from the user.
Input: Enter the number of elements: 4
Enter the number : 40
Enter the number : 69
Enter the number : 89
Enter the number : -54
Output: The largest number is : 89
In this program, the user needs to enter the total number of elements in which he wants to perform the comparison and the values. The program will compare all the elements and will return the value of the largest element.
Enter number of elements: 5
Enter the number : 20
Enter the number : -219
Enter the number : 219
Enter the number : 54.87
Enter the number : -1000
The largest number is : 219
Explanation: In the above program, we first take input values from the user. We take a variable temp which will store the size of an array. Then, the comparison is being made until we reach the last element. The loop is then terminated and the value of the largest element is returned to the user.
- How to find the index value of any element in slice of bytes in Golang?
- How to find the last index value of any element in slice of bytes in Golang?
- Program to shift all zero to the end of array in Golang
- Golang Program that Removes Duplicate Elements From the Array
- Program to find the Length of the longest substring without repeating characters in Golang
- Find the index of an array element in Java
- How to Get First and Last Element of Slice in Golang?
- How to replace a specified element in slice of bytes in Golang?
- Check if the specified element is present in the slice of bytes in Golang
- Golang | Searching an element of int type in slice of ints
- Searching an element of float64 type in Golang slice
- Searching an element of string type in Golang slice
- Golang program that uses structs as map keys
- Golang Program that uses String Switch
- Golang program that uses defer keyword
- Golang program that uses func with two arguments
- Golang program that uses fallthrough keyword
- Copy an Array by Value and Reference into Another Array in Golang
- Golang Program that Uses Multiple Return Values
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.