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
marissa [1.9K]
3 years ago
10

The function's only behavior should be to return the sum of array userVals' elements. What common error does the function make?

Computers and Technology
1 answer:
Leno4ka [110]3 years ago
5 0

Answer:

A. Attempts to access an invalid element.

Explanation:

The C program above is supposed to loops 10 times to get the total of the userVal's element, but the loop is assigning the cumulative sum of the to each nth index of the userVal array. Although the cumulative total of the array is assigned to the last index, the return statement is attempting to return an invalid element (since i is local only to the for loop statement). The program should return the userVal[9] instead.

You might be interested in
Write the following function without using the C++ string class or any functions in the standard library, including strlen(). Yo
dolphi86 [110]

Answer:

The function in C++ is as follows

int chkInd(string str1, string str2){    

int lenstr1=0;

while(str1[lenstr1] != '\0'){  lenstr1++;  }

int index = 0; int retIndex=0;

for(int i=lenstr1-1;i>=0; i--){

   while (str2[index] != '\0'){

       if (str1[i] == str2[index]){

           retIndex=1;

           break;         }

       else{   retIndex=0;      }

  index++;    }

  if (retIndex == 0){   return i;   }else{return -1;}}

}

Explanation:

This defines the function

int chkInd(string str1, string str2){    

First, the length of str1 is initialized to 0

int lenstr1=0;

The following loop then calculates the length of str1

while(str1[lenstr1] != '\0'){  lenstr1++;  }

This initializes the current index and the returned index to 0

int index = 0; int retIndex=0;

This iterates through str1

for(int i=lenstr1-1;i>=0; i--){

This loop is repeated while there are characters in str2

   while (str2[index] != '\0'){

If current element of str2 and str1 are the same

       if (str1[i] == str2[index]){

Set the returned index to 1

           retIndex=1;

Then exit the loop

           break;         }

If otherwise, set the returned index to 0

       else{   retIndex=0;      }

Increase index by 1

  index++;    }

This returns the calculated returned index; if no matching is found, it returns -1

  if (retIndex == 0){   return i;   }else{return -1;}}

}

4 0
3 years ago
Type the correct answer in the box. Spell all words correctly. What allows users to make long-distance calls over the Internet?
Mademuasel [1]

Answer:

Voice over internet protocol (VoIP)

Explanation:

It is a technology that allows you to make voice calls using a broadband Internet connection instead of a regular (or analog) phone line.

VoIP services convert your voice into a digital signal that travels over the Internet. If you are calling a regular phone number, the signal is converted to a regular telephone signal before it reaches the destination. VoIP can allow you to make a call directly from a computer, a special VoIP phone, or a traditional phone connected to a special adapter. In addition, wireless "hot spots" in locations such as airports, parks, and cafes allow you to connect to the Internet and may enable you to use VoIP service wirelessly.

7 0
4 years ago
Read 2 more answers
What shooting position is commonly used when hunting with a shotgun?
amid [387]
Standing well for me I never miss a shot in that position

6 0
4 years ago
Read 2 more answers
Elaboren un texto acerca de una caracteristica o<br>componente de algun sistema tecnologico.<br>​
LUCKY_DIMON [66]

Answer:

<em>Teniendo en cuenta el sistema hidráulico se puede mencionar la siguiente característica teniendo en cuenta el principio de Pascal:</em>

  • <u><em>La presión ejercida sobre un fluido en área pequeña es igual a las fuerza ejercida sobre un fluido en un área más grande.</em></u>

Explanation:

<em>El principio de Pascal menciona en términos generales que l</em><u><em>a fuerza ejercida sobre un fluido se ejerce sobre el total del fluido y en todas las direcciones</em></u><em>, sin embargo, basado en este concepto se encuentra el principio de la prensa hidráulica (que se menciona en la respuesta), el cual se podría expresar de la siguiente forma:</em>

  • <em>F1/A1 = F2/A2</em>

<em>Donde:</em>

  • <em>F </em><em>= Fuerza ejercida.</em>
  • <em>A</em><em> = Área en la cual se ejerce la fuerza.</em>

<em>Lo que se busca es ejercer una fuerza en un área pequeña que se vea reflejado como una gran fuerza en un área más grande. Éste principio se suele usar para el levantamiento de maquinaria como automóviles en los concesionarios.</em>

8 0
3 years ago
How to make a business plan​
Alborosie

Answer:

Traditional business plan format

Executive summary. Briefly tell your reader what your company is and why it will be successful. ...

Company description. ...

Market analysis. ...

Organization and management. ...

Service or product line. ...

Marketing and sales. ...

Funding request. ...

Financial projections.

Explanation:

Hope it helps

8 0
3 years ago
Other questions:
  • Ten 9600-bps lines are to be multiplexed using TDM. a. Ignoring overhead bits in the TDM frame, what is the total capacity requi
    6·1 answer
  • What is intergrated circuit ic​
    10·1 answer
  • Which of the following resources is an example of a web-based application?
    15·1 answer
  • Sukhi needs to insert a container into her form to collect a particular type of information. Which object should she insert?
    6·1 answer
  • . Which of the following is the correct syntax for a method header with parameters? a. public static void example(x, y) { b. pub
    8·1 answer
  • What is your favourite video game??​
    5·2 answers
  • Which protocol sends a request to view or download a website or file ​
    7·1 answer
  • Why do designers use tonal shading?
    10·2 answers
  • A software team is setting an automation strategy and begins by identifying business processes that could benefit from automatio
    12·1 answer
  • Create a program to determine the largest and smallest number out of 15 numbers entered (numbers entered one at a time). This sh
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!