Question

In the following example while loop, describe what the loop body executes: int i = 0;...

In the following example while loop, describe what the loop body executes:

int i = 0;

while (i < 10,000)

{

addObject (new Bee (), 110, 130);

i = i + 1;

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

while-Loop body is executing addObject method which is taking 3 parameters - an object of Bee Class and two constant values- 110 and 130

Add a comment
Know the answer?
Add Answer to:
In the following example while loop, describe what the loop body executes: int i = 0;...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please answer both questions thank you. Rewrite the following for loop into a while loop: int...

    Please answer both questions thank you. Rewrite the following for loop into a while loop: int s S = 0; for (int i = 1; i <= 10; i++) { S += i; int s = 0; int i = while (i <= 10) S = + i; i++; } int s = 0; int i = 1; while (i <= 10) { s = s + i; i++; } int S = 0; int i = 1; while (i...

  • Convert the following while loop into a for loop. int 1 - 50: int sum-07 while...

    Convert the following while loop into a for loop. int 1 - 50: int sum-07 while (sum < 1000) sum - sum + 1; Question 35 (2 points) Saved Given an int variable k that has already been declared, use a while loop to print a single line consisting of 80 dollar signs. Use no variables other than k. int sum = 0; for(int i = 100;sum < 10000;1-- sum = sum + i;

  • What are the values stored in the array a after the following code executes? int[] a...

    What are the values stored in the array a after the following code executes? int[] a = new int[10]; a[0] = 1; for (int i = 1; i < a.length; i++) a[i] = 2 * a[i - 1] - 1;

  • Write an expression that executes the loop while the user enters a number greater than or...

    Write an expression that executes the loop while the user enters a number greater than or equal to 0. Note: These activities may test code with different test values. This activity will perform three tests, with user input of 9, 5, 2, -1, then with user input of 0, -17, then with user input of 0 1 0 -1. Also note: If the submitted code has an infinite loop, the system will stop running the code after a few seconds,...

  • C++ 5.How many times will the following loop run? int i=5; while (i19) 6 . What...

    C++ 5.How many times will the following loop run? int i=5; while (i19) 6 . What is the output of the following code snippet? int time 1; int year2 int rate = 1; int principal = 5; int interest-0 cout <<i < endl while (year< 5) interest (principal * time rate) /1 ; cout << interest << endl; year++

  • Write an expression that executes the loop while the user enters a number greater than or...

    Write an expression that executes the loop while the user enters a number greater than or equal to 0. Note: These activities may test code with different test values. This activity will perform three tests, with userNum initially 9 and user input of 5, 2, -1, then with userNum initially 0 and user input of -17, then with userNum initially -1. See "How to Use zyBooks". . Also note: If the submitted code has an infinite loop, the system will...

  • C++ Visual Studio 1. How many iterations are in the following "while" loop? int i =...

    C++ Visual Studio 1. How many iterations are in the following "while" loop? int i = 0; while(i < 20) { ++i; } 2. How many iterations are in the following "for" loop? for(int i = 5; i < 17; i = i + 2) { // Work } How many times will '+' be printed? int i = 0; while(true) { if(i == 5) { break; } cout << "+"; ++i; } 3. How many times will '+' be...

  • using C++ 1. Convert the following while loop into a for loop: int count = 0;...

    using C++ 1. Convert the following while loop into a for loop: int count = 0; while (count < 10) x = count + sin(x); y = count + cos(y); count++;

  • in c++ language 1.Re-write the following for loop statement by using a while loop statement: int...

    in c++ language 1.Re-write the following for loop statement by using a while loop statement: int sum = 0; for(int i=0;i<=1000;i++){                 sum+=i; } 1 (b). Following is the main () function of a program. The program asks a user to enter 150 integers and print the largest integer user entered. int main() {    int score, highest;             //missing portion of the program             return 0;    } 1(c). Find the missing portion of the following code, so the...

  • For the C code 1 int loop while(int a, int b) int result 1; while (a < b) t result (atb); return ...

    For the C code 1 int loop while(int a, int b) int result 1; while (a < b) t result (atb); return result; Gcc generates the following assembly code: %ebp+8, mov1 movl movl %ebp+12 at 8(%ebp) ,%ecx 12(%ebp) ,%ebx $1,%eax a at b 5 jge L11 leal (%ebx, %ecx), Xodx 8 L12: inull %eax , %eax addl $1,%ecx addl $1, edx cmp1 %ecx , %ebx 9 10 12 13 J8 14 ·L11: .L12 In generating this code, occ makes an...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT