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
As you will solve more complex problems, you will find that searching for values in arrays becomes a crucial operation. In this
sergeinik [125]

Answer:

#include<iostream>

using namespace std;

int main() {

cout<<"Enter The Size Of Array: ";

int size;

bool isBestCase=false;

cin>>size;

if(size<=0){

cout<<"Error: You entered an incorrect value of the array size!"<<endl;

return(0);

}

int array[size], key;

cout<<"Enter the numbers in the array, separated by a space, and press enter:";

// Taking Input In Array

for(int j=0;j<size;j++){

cin>>array[j];

}

//Your Entered Array Is

for(int a=0;a<size;a++){

cout<<"array[ "<<a<<" ] = ";

cout<<array[a]<<endl;

}

cout<<"Enter a number to search for in the array:";

cin>>key;

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

 if(key==array[i]){

   if(i==0){

     isBestCase=true; // best case scenario when key found in 1st iteration

     break;

   }

 }

}

if(i != size){

 cout<<"Found value "<<key<<" at index "<<i<<", which took " <<++i<<" checks."<<endl;

}  else{

 cout<<"The value "<<key<<" was not found in array!"<<endl;

 cout<<"We ran into the worst-case scenario!"; // worst-case scenario when key not found

}

if(isBestCase){

cout<<"We ran into the best case scenario!";

}

return 0;

}

Explanation:

The C++ source dynamically generates an array by prompting the user for the size of the array and fills the array with inputs from the user. A search term is used to determine the best and worst-case scenario of the created array and the index and search time is displayed.

5 0
3 years ago
Terrence smiles at his customers, helps his cowokers,and stays late when needed. What personal skill does Terrence demonstrate
adell [148]

Answer: Humility,kindness

Explanation:

5 0
3 years ago
Read 2 more answers
Ask one of your parent, grandparent or elder relatives about the popular song during their time they consider their favorite. As
inysia [295]

Answer:

Babooshka by Kate bush

Explanation:

My dad likes this song because it has a very nice beat

I find this sond interesting because the vocals and pitch end up sounding different than you would expect them to be. Also the range of the singer (Kate bush) is amazing

4 0
3 years ago
Consider a distributed denial of service (DDOS) attack, Assume the attacker has compromised a number of broadband connected comp
Daniel [21]

Answer:

A ) 200 Zombie systems

B ) 200 Zombie systems

Explanation:

maximum uplink data rate : 512 kbps = 512 * 1000 * 8  = 4096000 bits/sec

Determine the number of 512 byte  ICMP echo packets = 512 * 8 = 4096 bits

hence the maximum number of 512-byte ICMP echo request (ping) packets a single zombie computer can send per second = 400 packets/sec

i.e. for 512kbps = 400 packets/sec

Determine the number of Zombie systems that the attacker will need to flood a target server

A) For a fast ethernet

A fast ethernet = 100 mbps

The number of Zombie systems needed = 1 zombie system * 200

and 1 zombie system = 512 kbps

therefore for a Fast ethernet the number of zombies systems needed = 200

B) For A Gigabit Ethernet

same as a fast ethernet system i.e. = 200

4 0
3 years ago
me pueden ayudar con mi trabajo sii porfss si me dan la respuesta correcta y les doy la mejor coronita si​
makkiz [27]

Answer:

Aver amiga te ayudo pero osi me sigues

Eso es muy fácil

6 0
3 years ago
Other questions:
  • Your game design company has recently asked all employees to use a specific personal information management application (PIM) to
    6·1 answer
  • Quien quiera jugar fortnote en una hora y media o antes pase id
    12·1 answer
  • Maia notices that her paragraphs are too close to one another. She wants to increase the space. Which arrangement of steps does
    6·2 answers
  • Can somebody tell me when is ps5 releasing???​
    15·2 answers
  • QUESTION 4 of 10: True or false: Paying for your ticket to a rock concert instead of a gym membership is an example of Opportuni
    9·1 answer
  • Zahra's softball team needs money for team T-shirts. The coach makes some fundraising suggestions, while team members brainstorm
    5·2 answers
  • When an instruction is sent to the CPU in a binary pattern, how does the CPU know what instruction the pattern means
    7·1 answer
  • Choose all of the items that represent parts of an operating system.
    6·2 answers
  • bro i got banned for posting an amazing bulk pic, but this dude literally posted an inappropriate, dafuq is wrong with this bann
    8·2 answers
  • What ethical concerns might arise from applying new IT to law enforcement?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!