You are on page 1of 3

Modul 02 looping

How to:
1. In this module, you are obligated to use loop.
2. Do not add specifications that are not required. If it is needed, you can add additional
specification on programs comment.
3. Pay attention to files name especially files extension (*.cpp). If the assistant cant open your
file,your work will not be graded.
4. Make sure your program can be compiled.
5. Add identity on every source, which at least contain:
//
//
//
//

SID/Name :
File name :
Date
:
Description :

6. All source codes file have to be compressed following the format in SOP.
7. All code should have indentation and comment (which explain each variable function, branching,
looping, function and procedure) to make it easier for debugging.
8. All form of cheating will be punished
9. Good Luck!

Problem 1
(save as: B02-NIM-YYMMDD-01.cpp)
Mister Vin is a librarian. In his free time, he likes to play with his computer. Today, he want to make
simple pattern such as triangle. Given an integer N, print out an isosceles right triangle with height
N.
Input & Output Format
(underline means input)
Input N : 3
***
**
*
Input N : 5
*****
****
***
**
*

Problem 2
(save as : B02-NIM-YYMMDD-02.cpp)
Mister Vin really love prime number. For him, prime number is a special number as special as
himself. If Mister Vin see a number in any place, he wants to know wether that number is a prime
number or not. Given an positive integer N, check if N is a prime or not.
(Note :1 is not a prime number!)
Input & Output Format
(underline means input)
Input N : 10
N is not a prime.
Input N : 23
N is a prime.

Problem 3
(save as : B02-NIM-YYMMDD-03.cpp)
Mister Vin become a judge in a beauty contest in his village. Because he too focus judging who will
become the winner, he forgot to choose the runner up. Given N distinct participants score, check
what is the runner up score (the second maximum score).
Input & Output Format
(underline means input)
Input N : 5
Input score 1 : 3
Input score 2 : 8

Input score 3 : 4
Input score 4 : 7
Input score 5 : 1
The second maximum score is 7

You might also like