- Sample 1
- Solution
- Sample 2
- Solution
- Sample 3
- Solution
Write a program to print integers from 1 to 6Output:
1
2
3
4
5
6
1
2
3
4
5
6
for Loop
- Example
- Flowchart
Example for Loop
- Example 1
- Example 2
- Example 3
Exercise for Loop
- Exercise 1
- Solution Exercise 1
- Exercise 2
- Solution Exercise 2
- Exercise 3
- Solution Exercise 3
Write a program using for loop to print odd integers from 1 to n (inclusive).Sample input:
10Sample output:
1 3 5 7 9
10Sample output:
1 3 5 7 9
while Loop
- Example
- Flowchart
Exercise while Loop
- Exercise 1
- Solution Exercise 1
- Exercise 2
- Solution Exercise 2
Write a program using while loop to print integers from n to 1.Sample input:
10Sample output:
10 9 8 7 6 5 4 3 2 1
do-while Loop
- Example
- Flowchart
Example do-while Loop
Exercise do-while Loop
- Exercise 1
- Solution Exercise 1
Write a program using do-while loop to display the multiplication table of numbers entered by the user.Sample input:
5Sample output:
5 x 1 = 5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
5 x 6 = 30
5 x 7 = 35
5 x 8 = 40
5 x 9 = 45
5 x 10 = 50\
5Sample output:
5 x 1 = 5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
5 x 6 = 30
5 x 7 = 35
5 x 8 = 40
5 x 9 = 45
5 x 10 = 50\
Nested Loops
- Sample 1
- Sample 2
- Sample 3
Exercise Nested Loops
Exercise 1 Rectangle
Exercise 1 Rectangle
- Question
- Solution
Make a program to display m × n rectangles formed with star characters (*). m is the length of the rectangle, and n is its width.Sample Input:
7 3Sample Output:
* * * * * * *
* * * * * * *
* * * * * * *
7 3Sample Output:
* * * * * * *
* * * * * * *
* * * * * * *
Exercise 2 NumericTriangle
Exercise 2 NumericTriangle
- Question
- Solution
Write a program to display a numeric triangle illustrated as follows.Sample Input:
5Sample Output:
1
12
123
1234
12345
5Sample Output:
1
12
123
1234
12345
Exercise 3 NumericTriangle2
Exercise 3 NumericTriangle2
- Question
- Solution
Write a program to display a numeric triangle illustrated as follows.Sample Input:
5Sample Output:
1
12
123
1234
12345
5Sample Output:
1
12
123
1234
12345
Exercise 4 NumericTriangle3
Exercise 4 NumericTriangle3
- Question
- Solution
Write a program to display a numeric triangle illustrated as follows.Sample Input:
5Sample Output:
1
121
12321
1234321
123454321
5Sample Output:
1
121
12321
1234321
123454321
Exercise 5 NumericTriangle4
Exercise 5 NumericTriangle4
- Question
- Solution
Write a program to display a numeric triangle illustrated as follows.Sample Input:
n = 5Sample Output:
1
121
12321
1234321
123454321
1234321
12321
121
1
n = 5Sample Output:
1
121
12321
1234321
123454321
1234321
12321
121
1
break dan continue
Using break
Using continue
Exercise break dan continue
- Exercise 1
- Solution Exercise 1
- Exercise 2
- Solution Exercise 2
By using break or continue, write a program to determine whether the number entered by the user is a prime number or not.Sample Input:
5Sample Output:
Prime
5Sample Output:
Prime
Tambahan Materi Nested Loops di kelas
Exercise 1 Digit Sum Sequence
Exercise 1 Digit Sum Sequence
- Question
- Solution
Tulis sebuah code program untuk menghitung total dari angka yang diinputkan oleh user.Sample Input:
Masukkan angka: = 12345Sample Output:
5 4 3 2 1
sum of digits: = 15
Masukkan angka: = 12345Sample Output:
5 4 3 2 1
sum of digits: = 15
Exercise 2 Nested Digit Sum Sequence one digit
Exercise 2 Nested Digit Sum Sequence one digit
- Question
- Solution
Tulis sebuah code program untuk menghitung total dari angka yang diinputkan oleh user.Sample Input:
Masukkan angka: = 12345Sample Output:
5 4 3 2 1
sum of digits: = 15
5 1
sum of digits: = 6\
Masukkan angka: = 12345Sample Output:
5 4 3 2 1
sum of digits: = 15
5 1
sum of digits: = 6\
Exercise 3 Fibonacci Custom Sum
Exercise 3 Fibonacci Custom Sum
- Question
- Solution
Sample Output:
1 1 2 3 5 8 13 12 7 10 8 9 17 17 16 15 13 10 5 6 11 …
1 1 2 3 5 8 13 12 7 10 8 9 17 17 16 15 13 10 5 6 11 …
Exercise 4 Check Digit Sum
Exercise 4 Check Digit Sum
- Question
- Solution
Status Exercise
Masukkan angka: = 123
Masukkan angka: = 456
Masukkan angka: = 451Sample Output:
1 + 2 = 3 (memenuhi syarat)
4 + 5 = 6 (tidak memenuhi syarat)
4 + 1 = 5 (memenuhi syarat)
ProgressSample Input:Masukkan angka: = 123
Masukkan angka: = 456
Masukkan angka: = 451Sample Output:
1 + 2 = 3 (memenuhi syarat)
4 + 5 = 6 (tidak memenuhi syarat)
4 + 1 = 5 (memenuhi syarat)


