Write a program to find minimum element from a list of element along with its index in
the list.
Answers
Answer:
Explanation:
Program in Python :
Explanation:
size=int(input("Enter the size of the list: "))#take input for the size of the list.
list1=[]#intialize the list.
for x in range(size):#for input the list.
value=int(input("Enter the value: "))#take the value for the list.
list1.append(value)#assign the value on the list.
minimum=list1[0]
for x in list1: #to find the minimum value of the list.
if(x<minimum):#check the minimum value.
minimum=x
print("The minimum value of the list",end=": ")#print the message.
print(list1,end="are ")#print the list.
print(minimum)#print the minimum value.
Output:
If the user input 1,2,3,4,5 for the list, then minimum value is 1.
Code Explanation:
The above code is in python language which holds the two loop.
First loop is used to take the value from the user and add it on the list.
Then the second loop traverse the list and find the minimum value from the list.
Then the list value and minimum value is printed on the screen by the help of print function