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
sashaice [31]
3 years ago
9

What is stored in str after the following code executes?

Computers and Technology
1 answer:
uranmaximum [27]3 years ago
6 0

Answer:

"CoCoComputer Science"

Explanation:

First let's understand how the loop works, then we'll see what it does.

The variable i is initialized to value 0.  Then inside the loop, it's incremented by 2 in each loop passage, while i < 8, so the loop will be processed with the following values of i: 0, 2, 4 and 6.  It will run a total of 4 times.

Let's examine the actions done during the FIRST loop:

(str equals "Computer Science", so indexOf('m') = 2, i = 0)

- if the index of 'm' within the string is < i  (index = 2, i = 0, FALSE)

does nothing

increases value of i by 2 (now i = 2)

Let's examine the actions done during the SECOND loop:

(str equals "Computer Science", so indexOf('m') = 2, i = 2)

- if the index of 'm' within the string is < i  (index = 2, i = 2,  FALSE)

does nothing

increases value of i by 2 (now i = 4)

Let's examine the actions done during the THIRD loop:

(str equals "Computer Science", so indexOf('m') = 2, i = 4)

- if the index of 'm' within the string is < i  ( index = 2,  i = 4, TRUE)

then str becomes "CoComputer Science"

increases value of i by 2 (now i = 6)

Let's examine the actions done during the FOURTH loop:

(str equals "CoComputer Science", so indexOf('m') = 4, i = 6)

- if the index of 'm' within the string is < i  (index = 4,  i = 6, TRUE)

then str becomes "CoCoComputer Science"

increases value of i by 2 (now i=8)

Loop ends because i = 8 (i < 8 becomes false)

You might be interested in
Which of the following does Not impact your credit score?
aleksandr82 [10.1K]

Answer:your race, gender, marital status, education level, religion, political party or income, those details can't be factored into your credit scores.

Explanation:

3 0
3 years ago
A collection of related instructions organized for a common purpose is referred to as
marshall27 [118]
Computer or data. Lol
5 0
3 years ago
Read 2 more answers
Unless you explicitly initialize global variables, they are automatically initialized to
shusha [124]

Answer:

Zero(0)

Explanation:

<u>Global Variables </u>

Variables which are declared outside any function. Any function can use these variables,they are automatically initialized to zero(0).They are generally declared before main() function.

Example- C program for showing global variable is 0.

  #include <stdio.h>

   int g;  // declaring g as global variable

   int main()

   {

       printf("%d",g);  //printing global variable

       return 0;

    }

<u>Output</u>

  0

4 0
3 years ago
We investigated a program which is probably used as one component of a bigger password breaking algorithm. We determined that th
Svetlanka [38]

Answer:

i dont know

Explanation:

3 0
3 years ago
Adding videos to your website can be tricky because there may be problems making sure they will play in all
Volgvan
The sentence ends with the word 'devices'
4 0
3 years ago
Other questions:
  • How would you describe enterprise computing
    12·1 answer
  • What does PHP stand for?
    9·2 answers
  • Susie works for an architectural firm and the partners have always drawn the plans for projects by hand. Though Susie learned ho
    8·1 answer
  • What is the radix transformation method?
    5·1 answer
  • How do I use this without the spring?
    6·1 answer
  • Let's go! About to hit 40k!!! Glad to help on Brainly®!!!
    11·1 answer
  • When referring to hard drives, access time is measured in
    11·1 answer
  • Match the characteristics to the mobile operating system that it describes.
    11·1 answer
  • 9. Which of the following is the<br>leading use of computer?​
    13·1 answer
  • What would a bar graph best be used for? State why and give 2-3 examples of things you could demonstrate with a bar graph
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!