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.
- Program to find the Length of the longest substring without repeating characters in Golang
- Program to shift all zero to the end of array in Golang
- Golang Program that Removes Duplicate Elements From the Array
- How to Copy an Array into Another Array in Golang?
- Copy an Array by Value and Reference into Another Array in Golang
- How to Get First and Last Element of Slice in Golang?
- Golang program that uses fallthrough keyword
- Golang Program that uses String Switch
- Golang Program that switch on floating-point numbers
- Golang program that uses structs as map keys
- Golang program that uses switch, multiple value cases
- Golang Program to Count Trailing Zeros in Factorial of a Number
- Golang program that uses func with variable argument list
- Golang program that uses func with two arguments
- Golang program that uses defer keyword
- Golang Program to Show the Duplicate Case Error in Switch Statement
- Golang Program that Uses Named Return Values and Defaults
- Golang Program that Removes Duplicates Using Nested Loops
- Golang Program that Uses Multiple Return Values
- Golang Program that uses func as Local Variable
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.