What is the output of the following loop? Comment on the code. (This is not the same as the previous exercise.)
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Absolute Java (6th Edition)
Additional Engineering Textbook Solutions
C Programming Language
Starting Out With Visual Basic (7th Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
Starting Out with Python (3rd Edition)
C How to Program (8th Edition)
- Write code that uses any type of loop. The code should continually ask for a user input and sums all user inputs that are divisible by 2. The loop should continue until the user enters a negative number. The code should output the sum a single time once user entry has completed. You may assume all libraries and namespaces have been previously written into the code, you are just writing everything that would go inside the main function (beyond the return 0:).arrow_forwardConsider the following for loop. int j, s;s = 0;for (j = 1; j <= 10; j++)s = s + j * (j - 1);In this for loop, identify the loop control variable, the initialization statement, loop condition, the update statement, and the statement that updates the value of s.arrow_forwardComplete the following sentence. There are two basic forms of loop constructs: while loops and loops.arrow_forward
- Write a loop of your choice that continues to read an integer x as long as x is not in the range of [5,10]. Complete the missing code in the space provided below. int x=1; *** sarrow_forwardWhat is the total number of iterations in the following loop ? for (int i=0; i<9; i+=2-1)arrow_forwarda and b are int variables containing values, and a < b.Write a for loop that prints all odd numbers from a to b (both inclusive).(Example: if a=25, b=82, then it will print 25 27 29 .... 79 81)Write only the for loop with its block, nothing else. with javaarrow_forward
- Please complete the following Java program using the math.random function. USE THE Math.random() class. DO NOT use arrays, the Random function. (i.e keep the program simple using while loops, if/else, for loops, etc)arrow_forwardThe following loop displays ? for (int i = 1; i <= 10; i++) { if (i > 5) { break; } System.out.print(i + " "); i++;arrow_forwardConvert the code below to use a for loop instead of a while loop. int num1 = 1; int num2 = 1; int num3 = 5; while (num1 < num3) { num2 = num1 * num2; System.out.println("num2: " + num2); num1++; } System.out.println("num1: " + num1); Javaarrow_forward
- How many times will the loop repeat? int j = 1; for(;<= 35; ) { } j++;arrow_forwardint toplam = 0;for (int i = 0; i < 10; i++){if (i % 2 == 1) continue;for (int j = 1; j <= 5; j++){if (i * j > 30) continue;toplam += j;}} What will be the total number of iterations when the code runs?arrow_forwarda and b are int variables containing values, and a > b.Write a for loop that prints even integer numbers from a to b (both inclusive).(Example: if a=41, b=16, then it will print 40 38 36 .... 18 16)Write only the for loop with its block, nothing else. This is a java question.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education