Loops (with solutions) - The Lack Thereof [PDF]

Exercise Worksheet. Java Software Solutions. Loops (with solutions). For exercises 1 to 15, indicate the output that wil

6 downloads 4 Views 16KB Size

Recommend Stories


Discovering Privacy—or the Lack Thereof
And you? When will you begin that long journey into yourself? Rumi

Jim Wallis' Politics - Or Lack Thereof
Almost everything will work again if you unplug it for a few minutes, including you. Anne Lamott

Planning with Loops
Silence is the language of God, all else is poor translation. Rumi

Closing the food loops
I cannot do all the good that the world needs, but the world needs all the good that I can do. Jana

samford university reconciliation and the lack thereof: atonement, ecclesiology, and the unity of god
Never let your sense of morals prevent you from doing what is right. Isaac Asimov

The complexity, or lack thereof, on a simian's face reveals a great deal about its society
Make yourself a priority once in a while. It's not selfish. It's necessary. Anonymous

with solutions
If you are irritated by every rub, how will your mirror be polished? Rumi

chromosome loops
Don't watch the clock, do what it does. Keep Going. Sam Levenson

Cosmic Loops
The greatest of richness is the richness of the soul. Prophet Muhammad (Peace be upon him)

PDF file with Ilan Vardi's solutions
Learn to light a candle in the darkest moments of someone’s life. Be the light that helps others see; i

Idea Transcript


Exercise Worksheet

Java Software Solutions

Loops (with solutions) For exercises 1 to 15, indicate the output that will be produced. Assume the following declarations are made just before each exercise. That is, assume these initializations are in effect at the beginning of each problem:

final int MIN = 10, MAX = 20; int num = 15;

1.

while (num < MAX) { System.out.println (num); num = num + 1; }

15 16 17 18 19

2.

while (num < MAX) { num = num + 1; System.out.println (num); }

16 17 18 19 20

3.

do {

16 17 18 19 20 21

num = num + 1; System.out.println (num); } while (num MIN) { System.out.println (num); num = num - 1; }

15 14 13 infinitely…

15 14 13 12 11

Exercise Worksheet

Java Software Solutions

6.

while (num < MAX) { System.out.println (num); num += 2; }

15 17 19

7.

while (num < MAX) { if (num%2 == 0) System.out.println (num); num++; }

16 18

8.

do {

21 num = num + 1; if (num*2 > MAX+num) System.out.println (num);

} while (num = 7; value++) System.out.println (value);

0 1 2 3 4 5 6 7

10.

for (int value=7; value < 0; value--) System.out.println (value);

7 6 5 4 3 2 1

11.

for (int value=1; value

Smile Life

When life gives you a hundred reasons to cry, show life that you have a thousand reasons to smile

Get in touch

© Copyright 2015 - 2024 PDFFOX.COM - All rights reserved.