Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a counting loop that initializes an int variable called begin to 2 and dou

ID: 3760921 • Letter: W

Question

Write a counting loop that initializes an int variable called begin to 2 and doubles this value

      each iteration until it reaches 65,536. The loop will contain a single line that increments the

      value of an int variable called counter.

for ( int begin = 2; begin < 65536; begin * 2 )

{

      counter++;

}

18. If the counter is initialized to 0 within counting loop in the question above(before incremented), what

      will the value of counter be when the loop ends? this is what need help with

Explanation / Answer

#include<iostream>

using namespace std;

int main()

{

int begin = 2;

int counter = 0;

  

for(begin=2;begin<65536;begin*=2)

counter++;

  

cout << counter;

return 0;

}

#include<iostream>

using namespace std;

int main()

{

int begin = 2;

int counter = 0;

  

for(begin=2;begin<65536;begin*=2)

{

counter = 0;

counter++;

}

cout << counter;

return 0;

}

Value of counter = 1

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote