Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 9 . 2 - Smallest value and index Write a function that returns the index of the smallest element ( first occurrance if multiple

Exercise 9.2- Smallest value and index
Write a function that returns the index of the smallest element (first occurrance if multiple) in a list of integers. Write the function using loop without using min function.
In the test program, ask user to enter 10 numbers, save them into a list, print the list, then call the function to display the smallest value and the index.
Sample output:
Enter number: 9
Enter number: 10
Enter number: 7
Enter number: 5
Enter number: 6
Enter number: 7
Enter number: 9
Enter number: 5
Enter number: 8
Enter number: 9
9,10,7,5,6,7,9,5,8,9
The smallest number is: 5
The index of the smallest element is: 3
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

What was the last book you read?

Answered: 1 week ago