1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Pie
3 years ago
15

Write a C++ function, smallestIndex, that takes as parameters an int array and its size and returns the index of the first occur

rence of the smallest element in the array. To test your function, write a main that prompts a user for a list of 15 integers and outputs the index and value of the first occurrence of the smallest value.
Computers and Technology
1 answer:
Oduvanchick [21]3 years ago
7 0

Answer:

Explanation:

The code in C++ is written as:

#include <iostream>

using namespace std;

int smallestIndex(int arr[],int size)

{

int min=arr[0],ind=0;

for(int i=0;i<size;i++)

{

if(min>arr[i])

{

min=arr[i];

ind=i;              NOTE: ind serves as a variable that is holding the smallest

}                                   element index of array

 

}

return ind;

}

int main() {

int arr[15];

cout<<"Enter 15 integers: ";

for(int i=0;i<15;i++)

cin>>arr[i];

for(int i=0;i<15;i++)

cout<<arr[i]<<" "<<endl;

int index=smallestIndex(arr,15);

cout<<"The position of the first occurrence of the smallest element in list is: "<<index<<endl;

cout<<"The smallest element in list is: "<<arr[index];

}

OUTPUT:

Enter 15 integers:

4

5

8

4

6

1

2

1

4

5

7

9

5

7

8

4   5  8  4  6  1  2  1  4  5  7  9  5  7  8  

The position of the first occurrence for the smallest element in the list is 5

The smallest element in the list is: 1

You might be interested in
True or False: You cannot restore a deleted file on a volume protected by the Recycle Bin. Select one: a. False b. True
artcher [175]

Answer:

The answer is false

Explanation:

When you delete a file imagine you are erasing the path there. The file still will exist until it is wrote over. If you wish to retrive it many programs can do it for you.

5 0
4 years ago
The ________ is the biggest power consumer on a mobile computing device.
AleksandrR [38]

The part of a computing device that is the biggest power consumer is;

Central Processing Unit

<h3>Central Processing Unit</h3>

The part of a computing device that cosnumes the most power is called the Central Processing Unit (CPU). This is due to the following reasons;

  • The CPU consists of motherboard and battery that draws power from the socket.

  • The Mother board is equipped with logic gates that are used to implement logic in the computer.

  • The Logic gates are voltage signals that signify the binary information that are fed into the system.

Read more about Central Processing Unit (CPU) at; brainly.com/question/4558917

5 0
3 years ago
Please help!!!
artcher [175]

Answer:

Draw on the screen or create images. Can I be called Brainliest pls

4 0
3 years ago
Read 2 more answers
How to connect local account to domain account?
muminat
<span>Join them to the domain
Login with their domain credentials, logout
Login as local administrator (not the old account, not the new one, a 3rd local admin)
Right click My Computer and select properties
Select advanced system settings
Go to the Advanced tab
Click settings under user profiles
Select their old profile you want and click Copy to
Browse to the location of their new profile and overwrite it</span>

If the Copy button is grayed out then reboot and repeat steps two to nine.

8 0
4 years ago
To locate a value in an ordered array of 100 items, binary search must examine at most ________ values.
vodka [1.7K]

To locate a value in an ordered array of 100 items, using binary search, requires examining at most _________ values.

7

5 0
2 years ago
Other questions:
  • Is this picture the CPU, RAM, CD, or Operating System
    15·1 answer
  • Most OEMs recommend that the engine oil be replaced and a new filter installed at which of the following mileage intervals ?
    7·1 answer
  • Which topology connects all the computers in a circular pattern
    13·2 answers
  • What problem does chlorofluorocarbon (CFC) create?
    5·1 answer
  • Write a function called matches that takes two int arrays and their respective sizes, and returns the number of consecutive valu
    6·1 answer
  • Question 14 (3 points)
    5·1 answer
  • Will mark brainliest if correct. First come, first serve.
    10·1 answer
  • 2. Why don't all buses on a motherboard operate at the same speed?​
    6·1 answer
  • How can you know if the information is based on scientifically collected data and if it's corroborated by other sources? Follow
    7·2 answers
  • Brian needs to see the space available to insert content on a slide in his presentation which feature of the presentation should
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!