Absolute Java (6th Edition)
6th Edition
ISBN: 9780134041674
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 3, Problem 29STE
Explanation of Solution
Given: The following code:
for (int n = 10; n > 0; n = n - 2)
System.out.println("Hello " + n);
To find: The output of the
for (int n = 10; n > 0; n = n - 2)
System.out.println("Hello " + n);
Solution:
The possible output of the program will be:
Hello 10
Hello 8
Hello 6
Hello 4
Hello 2
In a for loop, the value of n variable has been initialized with 10 and the condition, (n > 0), will be true because 10 > 0...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
What is the value of x when i = 4?
#include
int main (void) {
int x =
for (int i = 0; i <= 4; ++i) {
X = X + i;
}
printf("%d %d", i, x);
return 0;
}
Please help me indicate output
What output is produced by the following code?int n;for (n = 1; n > 4; n++)System.out.println(n);
Chapter 3 Solutions
Absolute Java (6th Edition)
Ch. 3 - Write an if-else statement that outputs the word...Ch. 3 - Suppose savings and expenses are variables of type...Ch. 3 - Suppose number is a variable of type int. Write an...Ch. 3 - Suppose salary and deductions are variables of...Ch. 3 - What output will be produced by the following...Ch. 3 - What would be the output in Self-Test Exercise 5...Ch. 3 - What would be the output in Self-Test Exercise 5...Ch. 3 - Write a multiway if-else statement that classifies...Ch. 3 - Prob. 9STECh. 3 - Prob. 10STE
Ch. 3 - Prob. 11STECh. 3 - Prob. 12STECh. 3 - Prob. 13STECh. 3 - Suppose are two variables that have been given...Ch. 3 - Prob. 15STECh. 3 - Assume that nextword is a String variable that has...Ch. 3 - Write an if-else statement that outputs the word...Ch. 3 - Write an if-else statement that outputs the word...Ch. 3 - Determine the value, true or false, of each of the...Ch. 3 - Does the following sequence produce a division by...Ch. 3 - Prob. 21STECh. 3 - Prob. 22STECh. 3 - What output would be produced in Self-Test...Ch. 3 - What is the output produced by the following?
Ch. 3 - What output would be produced in Self-Test...Ch. 3 - Prob. 26STECh. 3 - What is the most important difference between a...Ch. 3 - Prob. 28STECh. 3 - Prob. 29STECh. 3 - What is the output of the following?
Ch. 3 - Rewrite the following for statement as a while...Ch. 3 - What is the output of the following loop? Identify...Ch. 3 - What is the output of the following loop? Comment...Ch. 3 - Prob. 34STECh. 3 - For each of the following situations, tell which...Ch. 3 - What is the output of the following?
Ch. 3 - What is the output of the following?
Ch. 3 - What is the output produced by the following?...Ch. 3 - What is the output produced by the following?...Ch. 3 - Fix the bug in the code in the earlier subsection...Ch. 3 - Add some suitable output statements to the...Ch. 3 - What is the bug in the following code? What do you...Ch. 3 - Prob. 43STECh. 3 - What numbers could be generated by...Ch. 3 - What numbers could be generated by...Ch. 3 - Use the method Math. random to generate a random...Ch. 3 - (This is a version of Programming Project 2.1 from...Ch. 3 - A designer is trying to create a new pattern of...Ch. 3 - Weight is defined as the gravitational force...Ch. 3 - It is difficult to make a budget that spans...Ch. 3 - You have just purchased a stereo system that cost ...Ch. 3 - The Fibonacci numbers Fn are defined as follows:...Ch. 3 - An Armstrong number is an n-digit number that...Ch. 3 - In a certain code language, numerals are each...Ch. 3 - Write a program that calculates the total grade...Ch. 3 - The game of Pig is a simple two-player dice game...Ch. 3 - You have three identical prizes to give away and a...Ch. 3 - Redo or do for the first time Programming Project...Ch. 3 - The file words. txt on the hook's website contains...Ch. 3 - The file words. txt on the book's website contains...Ch. 3 - This problem is based on a "Nifty Assignment" by...Ch. 3 - Prob. 16PP
Knowledge Booster
Similar questions
- What is the final value of x when the following code is run? int x;for(x =1; x<20; x+=2) {}arrow_forward5- What is the output for y? int y = 0; for (int i = 0; i< 10; ++i) { y +=i; } cout << y;arrow_forwardWhat output is produced by the following code?for (int n = 4; n > 0; n––)System.out.println(n);arrow_forward
- In c void f (int *p, int * const q) { p=q *p=3; *p=4; } int i = 1, j =2; int main(){ f(&i, &j); printf("%d %d",i,j); return 0; } a. The program prints 1 2 and terminates b. the program prints 1 3 and 0 c. the program prints 1 4 and terminates d. the program prints 3 4 and terminates e. the program has compiler errorarrow_forwardI need help with this problem. Please help me, because I do not understand. if 14 > 7: print("Greater than 14") x = 2 print(x * 7) else: print("Less than") print(7)arrow_forward%% [0-9] printf("number"); [a-zA-Z] printf("letter"); T+EN+ printf("10"); According to the above lex rules, what is the expected output for the following inputs? TTENN TEEN 10arrow_forward
- Problem specification: There is a grid of NXN squares. We can easily determines how many different rectangles (squares are excluded) there are in the grid. For example, in a 3X3 grid, you can find 22 different rectangles, marked as the green rectangles. You can see that we did not count the red ones as they are squares. In this assignment, you will write a Java program that takes the value of N as input and determines the total area of all the rectangles in the grid. Assume that the smallest squares in the grid have length 1. So a 3X2 rectangle will have an area of 6. For example, the total area of all the rectangles in the 3X3 grid is 66.…arrow_forwardWhat is the output of this code? def func(a,b): if(b==1): return a else: return a* func(a,b-1) A It adds a and b (B) None of these choices © It multiplies a and b (D) It raises a to the power of barrow_forwardzain IQ docs.google.com Q The general form of (Compound if) is: If (condition); {statmenet1; } else {statmenet1; } * true False Int mark [5]= { 3, 77, 40, 1233}; * true O False 7. The output of this program is(49): int main ( ){int a=4,sum; while (a<=10) {sum+=a; a+=1;}cout << "The Total = << sum ;} * true Falsearrow_forward
- What is the error(s) in this code? If num1 = num2: print ("They are equal) else print ("They are not equal")arrow_forwardWrite only in javaarrow_forward3. What does this code print? int i = 0; while (i < 12) { int j; for (j = 0; j < i; j++) { if ((i+j)%3 Ø) == j += 2; } i += j+1; } System.out.println("i = "+i);arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education