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
Naya [18.7K]
3 years ago
10

Write a C++ function, lastLargestIndex that takes as parameters an int array and its size and returns the index of the last occu

rrence of the largest element in the array. Also, write a program to test your function.This solution contains errors:#includeint largestIndex(int list[], int listSize);int main(){int alpha[20];cout << "The index of the first occurrence of the largest element in the array is " << largestIndex(alpha,20) << endl;return 0;}int largestIndex(int list[], int listSize){int i;int minIndex = 0; //Assuming first element is the largestfor (counter = 1; counter < listSize; counter++)if (list[maxIndex] < list[counter])maxIndex = counter;return maxIndex;}
Computers and Technology
1 answer:
likoan [24]3 years ago
6 0

Answer:

#include <iostream>

using namespace std;

int largestIndex(int list[], int listSize);  

int main()  

{  

   int alpha[10] = { 3, 6, 2, 6, 4, 1, 0, 5, 4, 2 };

   cout << "The index of the last occurrence of the largest element in the array is " << largestIndex(alpha, 10) << endl;  

   return 0; }

int largestIndex(int list[], int listSize) {

 

   int largestIndex = 0;  

   

   for (int counter = 1; counter < listSize; counter++)

       if (list[counter] >= list[largestIndex])

           largestIndex = counter;

   return largestIndex;

}

Explanation:

The function keeps track of the index of the largest value and updates it when the same or a larger value is found.

You might be interested in
A spreadsheet will complete a variety of mathematical formulas for the user.<br><br> True or false
Lady bird [3.3K]

Answer: True

Explanation:

A spreadsheet will complete any formula as long as its entered by the user

6 0
3 years ago
Read 2 more answers
Cindy Vindoolo logged on to her e-mail account to find that she had received 50 e-mails from a company called LifeCo that promis
zmey [24]

Answer:

Option C i.e., spam is the correct answer to the following question.

Explanation:

The following mails are spam because when Cindy opens her mail account then, Cindy finds that she gets 50 emails from the unknown company which promises the weight loss if she will buy pills form that company named "LifeCo.". Cindy gets that these companies are fraud or they cheat so they deleted those messages angrily because those are spam.

5 0
4 years ago
Write the function listBuilder(l1, length) that takes a list of strings called l1 and an int called length and returns another l
Grace [21]

Answer:

The solution code is written in Python 3:

  1. def listBuilder(l1, length):
  2.    result = []
  3.    for x in l1:
  4.        if(len(x) >= length):
  5.            result.append(x)
  6.    return result

Explanation:

Firstly, we create a variable result to hold the list will be returned at the end of the function. (Line 1)

Next, we create a for-loop to traverse the string in the l1 list (Line 4) and check for each string if their length is equal or bigger than the input length (Line 5). If so, we use append method to add the string to the result list.

At the end, return the result list as output (Line 8).

7 0
4 years ago
Which one of the following business names would be rated Incorrect for name accuracy? Answer McDonald's McDonald's H&amp;M McDon
Damm [24]

McDonald's H&M McDonalds Inc is incorrect for name accuracy.

Explanation:

The correct Name is McDonald's. But Mc Donald's H&M and McDonalds inc is incorrect for name accuracy.

McDonald's is a fast-food company based in America. It has its retail outlets throughout the world. It is very famous for its burgers and french fries. It is the world's second-largest employer in the private sector. It is a symbol of globalization as it has its outlets throughout the world.

6 0
4 years ago
For this question you should write code using the tools you learned so far. The code will find all the integers in the interval
kvasek [131]

Answer:

The code in Python 3.7 than answers this question is given below:

def main():

 cont = 0

 for i in range(1, 12001):

   if i%3 == 0 and i%14 == 0:

     print(i)

     cont += 1

 print("{} numbers are divisible by 3 and 14".format(cont))

if __name__== "__main__":

 main()

Explanation:

#Create the main function, inside this is our logic to solve the problem

def main():  

#Define a cont variable that storage the amount of numbers that satisfy the condition given

 cont = 0  

 #For loop between 1 and 12000

 for i in range(1, 12001):

   #Use the mod function to know if is divisible by 3 and by 14

   if i%3 == 0 and i%14 == 0:

     #Print the number that satisfy the condition

     print(i)    

     #Refresh the cont variable if the condition is satisfied

     cont += 1

     #Print the output  

  print("{} numbers are divisible by 3 and 14".format(cont))

if __name__== "__main__":  

 #Run the main function

 main()  

 

8 0
4 years ago
Other questions:
  • Is it bad to leave a co2 cartridge in an airsoft pistol?
    6·2 answers
  • Two electronics technicians are discussing electrical quantities. Technician A says that resistance is an opposition to electric
    6·1 answer
  • What two methods can be used to access and modify an existing program that is running on an iot device in cisco packet tracer? (
    6·1 answer
  • What is Adobe Dreamweaver ? What is it used for ? Name and describe its major components and features in detail​
    15·1 answer
  • Which extension is appropriate for Word document templates?
    13·2 answers
  • The following code will not compile. Which of the options below would allow the code to compile and run as intended?
    9·1 answer
  • What is DMTS. Explain it​
    10·2 answers
  • My chrome book computer clock is an hour off how do I fix that
    14·1 answer
  • Please please help ASAP it’s timed
    13·1 answer
  • ((Excel)) please help, 100 points, and brain crown thingy, not only that, i will make several of these so you can get several hu
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!