0% found this document useful (0 votes)
4 views19 pages

L5_-_Java__Practice_Problems_Intermediate

The document outlines a practice session for intermediate Java, covering topics such as the FizzBuzz problem, loops, and digit manipulation. It includes exercises like finding the number of digits, summing digits in a range, and checking for prime numbers. The session emphasizes variations of the FizzBuzz problem and provides examples for practice.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views19 pages

L5_-_Java__Practice_Problems_Intermediate

The document outlines a practice session for intermediate Java, covering topics such as the FizzBuzz problem, loops, and digit manipulation. It includes exercises like finding the number of digits, summing digits in a range, and checking for prime numbers. The session emphasizes variations of the FizzBuzz problem and provides examples for practice.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

L5 - Java

Practice Session (Intermediate)


RECAP

1. FizzBuzz Problem

2. Break
a) Danger_number
b) FizzBuzz variation: stop as soon as sum of i’s exceeds 3*N

3. Continue
a) FizzBuzz variation: Do nothing if i is a multiple of 4.

4. Practice:
a) Find number of digits of a given number
b) Find sum of digits of a given number
c) Print sum of digits for all the numbers in a given range [L, R]
Given a value of N,
print only those numbers
from 1 to N that have
sum of digits = K
What if updation is
not the same
everytime?
While Loop int i =
1;

(--condition ) [ While (ic = 20] [


While
.

out-printen (c),
I body System.
i + +j
3
3 END

-> condition
>
-
do >
-
condition
don
do- condition >
-

Condition >
-
>
Do While Loop
/Erbes
1 - 1

2 -> 2

15
k
i
=

L
10 + ( Output : 69
Print first N numbers 78
? that have their
87
14- 5 sum of digits = K
96
↓ 159
63 - I


CS6 - 22

(1) 87 +
25(3) 225 98 -

69-15 13
! 157 +

1592
I ISS th

78-252)
96 -
25(a) 1357 12
I5 -
More
Practice
Given a positive number, check if
it’s prime or not
Thank You!

You might also like