100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Written assigment sc025 KOLEJ MATRIKULASI LABUAN $13.29   Add to cart

Exam (elaborations)

Written assigment sc025 KOLEJ MATRIKULASI LABUAN

 22 views  0 purchase
  • Course
  • Institution

Written assigment sc025 KOLEJ MATRIKULASI LABUAN

Preview 3 out of 18  pages

  • June 3, 2024
  • 18
  • 2023/2024
  • Exam (elaborations)
  • Questions & answers
avatar-seller
WRITTENASSIGNMENT
(SC025)




by

YOUR NAME : Nur Afiezah Binti Masno
MATRIC NO : MS2215271612
TUTORIAL GROUP : K10
LECTURER' NAME : Mardawiah Binti Tawil




1

,TABLE OF CONTENT


1.1 Introduction to Array........................................................................................

1.2 Declare, create, and initialize an array.....................................................3

1.3 Access array elements using indexes.......................................................4

1.4 Array operation.........................................................................................5

Input elements.....................................................................................

Display elements..................................................................................

Linear search......................................................................................

2.0 Introduction to Problem-Solving

2.1 Problem analysis (IPO).................................................................................7

2.2 Algorithm ( flowchart)....................................................................................8

2.3 Implementation.............................................................................................8

2.4 Testing.........................................................................................................13

2.5 Documentation............................................................................................15

3.0 Conclusion..........................................................................................................17

4.0 References.........................................................................................................17




2

, PART A
1.1 Introduction to array
An array is an ordered sequence of the same type of data. In Java, an array is an ordered
indexed collection of data values of the same type. Most of the algorithm and problem-
solving approaches use array in their implementation. An array consists of its data type, size,
index and value. The elements are stored at contiguous memory locations in an array. Array
have a fixed size where the size of the array is defined when the array is initialized.


1.2 Declare, create, and initialize an array
To declare, create, and initialize an array in a programming language, first, you declare the
array by specifying its type and name. For example, in Java, you would declare an array of
integers like this: "int [] myArray;". Then, you create the array by allocating memory for it.
This is done using the "new" keyword in Java: "myArray = new int [5];", which creates an
array of integers with a size of 5. Finally, you initialize the array by assigning values to its
elements. This can be done individually using index notation: "myArray [0] = 1;", "myArray
[1] = 2;", and so on, or you can initialize the array during declaration: "int [] myArray = {1, 2,
3, 4, 5};". This process allows for the efficient storage and manipulation of data in the array
for various programming tasks.
Declare an array
Syntax : DataType[] ArrayName;
Examples to declare an array :

int[] list;
String[] fruits;
float[] prices;

Creating an array
There are two ways to do this which are using new operator and directly initialising the
contents of the array.
a) Using new operator
Arrayname is the name of the array. Datatype is the type of elements the array is going to
store. SIZE is the number of elements that will be stored in the array
Syntax : Arrayname = new Datatype[SIZE];
Examples :
list = new int[10];
fruits = new String[5];
3
prices = new float[4];

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller nurafiezah. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $13.29. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

75323 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$13.29
  • (0)
  Add to cart