Mth from Hafiz Safwan
Monday, 20 May 2013
Saturday, 11 May 2013
Monday, 25 March 2013
Monday, 18 March 2013
Types of sequence
1. Arithmetic Sequences
2. Geometric Sequences
3. Special Number Sequences
·
Triangle Numbers
·
Square Numbers
·
Cube Numbers
·
Fibonacci Numbers
Give 1 example sequences use in computer programming
Sequence
in computer programming is the default control structure, instructions are
executed one after another. They might, for example, carry out a series of
arithmetic operations, assigning results to variables
Example:-
Make a list
number of 100 students that attend “seminar keusahawanan”.
Pseudocode
BEGIN
Declare a list as an array with 100
elements
for (int student = 0, student<100;
student++){
list[student] = student + 1 à (arithmetic operation)
print list[student]
}
END
Answer:
No.Student
= 0
Print
list[student] = 1
No.Student
= 1
Print
list[student] = 2
.
.
.
.
Print
list[student] = 99
No.Student
= 100
Source
Code
public
class sequences {
public static void main(String[]
args) {
int list [] = new int[100];
for(int student = 0; student<100;
student++) {
list[student] = student
+ 1;
System.out.println(list[student]);
}
}
}
Monday, 11 March 2013
Subscribe to:
Posts (Atom)