SlideShare a Scribd company logo
Page 1 of 3
2.2 Programming
2.2.2 Data structures; arrays
Define and use arrays (one- and two-dimensional) for solving simple problems (this should include
initializing arrays, reading data into arrays and performing a simple serial search on a one-dimensional
array)
A data structure is a collection of different data items that are stored together in a clearly defined way. Two
common data structures are arrays and records.
Array
An array is a data structure, which allows a set of items of identical data type to be stored together using the
same identifier name.
Arrays are declared in a similar way to standard variables, except that the array size and dimensions are
included. For example, the following declares an array that reserves five locations in memory and labels these
as ‘Names’:
DIM Names(4) As String
The five individual locations are Names(0), Names(1), Names(2), Names(3), Names(4).
Each data item is called an element of the array. To reference a particular element a programmer must use the
appropriate index. For example, the following statement assigns data to the 5th
element:
Names(4) = “John”
Arrays simplify the processing of similar data. An algorithm for getting five names from the user and storing
them in the array Names is shown below:
Dim Names(4) As String
Dim name As String
For i=0 to 4
Input name
Names(i)=name
Next i
Page 2 of 3
2.2 Programming
2.2.2 Data structures; arrays
One-dimensional arrays
A one-dimensional array is a data structure in which the array is declared using a single index and can be
visually represented as a list.
The following diagram shows the visual representation of the array Names(4):
Page 3 of 3
2.2 Programming
2.2.2 Data structures; arrays
Array Questions:
Question 01: Input and store the names and marks for 30 students who have sat three computer science tests.
Test 1 is out of 20 marks, Test 2 is out of 25 marks, Test 3 is out of 35 marks. You must store the names in a
one-dimensional array and the marks and total score for each student in one-dimensional arrays. All the marks
must be validated on entry and any invalid marks rejected. You may assume that the students’ names are
unique.
Question 02: Calculate and store the total score for each student and calculate the average score for the whole
class. Output each student’s name followed by their total score, and then output the average score for the
class.
Question 03: Select the student with the highest score and output their name and score.
Your program must include appropriate prompts for the entry of data. Error messages and other output need to
be set out clearly and understandably. All variables, constants and other identifiers must have meaningful
names. Each task must be fully tested.
Question 04: Write a pseudocode using array, asks user to input 10 numbers, then calculates the average of
those numbers. Loop is used in this problem.
Question 05: Write a pseudocode to swap first and last element of an integer 1-d array.
Question 06: Write a pseudocode to find the largest and smallest element of an array.

More Related Content

What's hot

Data Types | CS8251- Programming in c | Learn Hub
Data Types | CS8251- Programming in c | Learn HubData Types | CS8251- Programming in c | Learn Hub
Data Types | CS8251- Programming in c | Learn Hub
Learn Hub
 
Data structures using C
Data structures using CData structures using C
Data structures using C
Prof. Dr. K. Adisesha
 
Lesson 2.2 abstraction
Lesson 2.2   abstractionLesson 2.2   abstraction
Lesson 2.2 abstraction
MLG College of Learning, Inc
 
Devry bis 155 week 1 quiz new
Devry bis 155 week 1 quiz newDevry bis 155 week 1 quiz new
Devry bis 155 week 1 quiz new
uopassignment
 
Unit 1 introduction to data structure
Unit 1   introduction to data structureUnit 1   introduction to data structure
Unit 1 introduction to data structure
kalyanineve
 
Description of data
Description of dataDescription of data
Description of data
Johnna Mae Yodico
 
Data Structures Chapter-4
Data Structures Chapter-4Data Structures Chapter-4
Data Structures Chapter-4
priyavanimurugarajan
 
Decision tree induction
Decision tree inductionDecision tree induction
Decision tree induction
thamizh arasi
 
MICRO PROJECT 22319 DMS
MICRO PROJECT 22319 DMSMICRO PROJECT 22319 DMS
MICRO PROJECT 22319 DMS
ARVIND SARDAR
 
Micro project project co 3i
Micro project project co 3iMicro project project co 3i
Micro project project co 3i
ARVIND SARDAR
 
Dbms question
Dbms questionDbms question
Dbms question
Ricky Dky
 
CIS 1403 Lab 2- Data Types and Variables
CIS 1403 Lab 2- Data Types and VariablesCIS 1403 Lab 2- Data Types and Variables
CIS 1403 Lab 2- Data Types and Variables
Hamad Odhabi
 
Lecture 2a arrays
Lecture 2a arraysLecture 2a arrays
Lecture 2a arrays
Victor Palmar
 
Data Structures (BE)
Data Structures (BE)Data Structures (BE)
Data Structures (BE)
PRABHAHARAN429
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
Radhika Puttewar
 
Binary tree
Binary treeBinary tree
Binary tree
Maria Saleem
 
4.arrays
4.arrays4.arrays
4.arrays
Hardik gupta
 
2 data structure in R
2 data structure in R2 data structure in R
2 data structure in R
naroranisha
 
DATA STRUCTURES - SHORT NOTES
DATA STRUCTURES - SHORT NOTESDATA STRUCTURES - SHORT NOTES
DATA STRUCTURES - SHORT NOTES
suthi
 
04 Classification in Data Mining
04 Classification in Data Mining04 Classification in Data Mining
04 Classification in Data Mining
Valerii Klymchuk
 

What's hot (20)

Data Types | CS8251- Programming in c | Learn Hub
Data Types | CS8251- Programming in c | Learn HubData Types | CS8251- Programming in c | Learn Hub
Data Types | CS8251- Programming in c | Learn Hub
 
Data structures using C
Data structures using CData structures using C
Data structures using C
 
Lesson 2.2 abstraction
Lesson 2.2   abstractionLesson 2.2   abstraction
Lesson 2.2 abstraction
 
Devry bis 155 week 1 quiz new
Devry bis 155 week 1 quiz newDevry bis 155 week 1 quiz new
Devry bis 155 week 1 quiz new
 
Unit 1 introduction to data structure
Unit 1   introduction to data structureUnit 1   introduction to data structure
Unit 1 introduction to data structure
 
Description of data
Description of dataDescription of data
Description of data
 
Data Structures Chapter-4
Data Structures Chapter-4Data Structures Chapter-4
Data Structures Chapter-4
 
Decision tree induction
Decision tree inductionDecision tree induction
Decision tree induction
 
MICRO PROJECT 22319 DMS
MICRO PROJECT 22319 DMSMICRO PROJECT 22319 DMS
MICRO PROJECT 22319 DMS
 
Micro project project co 3i
Micro project project co 3iMicro project project co 3i
Micro project project co 3i
 
Dbms question
Dbms questionDbms question
Dbms question
 
CIS 1403 Lab 2- Data Types and Variables
CIS 1403 Lab 2- Data Types and VariablesCIS 1403 Lab 2- Data Types and Variables
CIS 1403 Lab 2- Data Types and Variables
 
Lecture 2a arrays
Lecture 2a arraysLecture 2a arrays
Lecture 2a arrays
 
Data Structures (BE)
Data Structures (BE)Data Structures (BE)
Data Structures (BE)
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Binary tree
Binary treeBinary tree
Binary tree
 
4.arrays
4.arrays4.arrays
4.arrays
 
2 data structure in R
2 data structure in R2 data structure in R
2 data structure in R
 
DATA STRUCTURES - SHORT NOTES
DATA STRUCTURES - SHORT NOTESDATA STRUCTURES - SHORT NOTES
DATA STRUCTURES - SHORT NOTES
 
04 Classification in Data Mining
04 Classification in Data Mining04 Classification in Data Mining
04 Classification in Data Mining
 

Similar to Data structures; arrays By ZAK

arrays.docx
arrays.docxarrays.docx
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptx
SajalFayyaz
 
DSA-Lecture-05
DSA-Lecture-05DSA-Lecture-05
DSA-Lecture-05
Haitham El-Ghareeb
 
Data structures "1" (Lectures 2015-2016)
Data structures "1" (Lectures 2015-2016) Data structures "1" (Lectures 2015-2016)
Data structures "1" (Lectures 2015-2016)
Ameer B. Alaasam
 
September 9 2008
September 9 2008September 9 2008
September 9 2008
napzpogi
 
Mca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structureMca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structure
Rai University
 
Arrays
ArraysArrays
Arrays
ViniVini48
 
Bsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structureBsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structure
Rai University
 
C programming session 04
C programming session 04C programming session 04
C programming session 04
Dushmanta Nath
 
Chapter 4 (Part I) - Array and Strings.pdf
Chapter 4 (Part I) - Array and Strings.pdfChapter 4 (Part I) - Array and Strings.pdf
Chapter 4 (Part I) - Array and Strings.pdf
KirubelWondwoson1
 
Bca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structureBca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structure
Rai University
 
Data Structures And Algorithms Roadmap for Beginners By ScholarHat PDF
Data Structures And Algorithms Roadmap for Beginners  By ScholarHat PDFData Structures And Algorithms Roadmap for Beginners  By ScholarHat PDF
Data Structures And Algorithms Roadmap for Beginners By ScholarHat PDF
Scholarhat
 
UNIT-5_Array in c_part1.pptx
UNIT-5_Array in c_part1.pptxUNIT-5_Array in c_part1.pptx
UNIT-5_Array in c_part1.pptx
sangeeta borde
 
Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional array
Rajendran
 
2D Array
2D Array 2D Array
2D Array
Ehatsham Riaz
 
M v bramhananda reddy dsa complete notes
M v bramhananda reddy dsa complete notesM v bramhananda reddy dsa complete notes
M v bramhananda reddy dsa complete notes
Malikireddy Bramhananda Reddy
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
KristinaBorooah
 
Array
ArrayArray
Array
Deep Shah
 
Array
ArrayArray
Advanced Data Structures And Algorithms Roadmap By ScholarHat PDF
Advanced Data Structures And Algorithms Roadmap By ScholarHat PDFAdvanced Data Structures And Algorithms Roadmap By ScholarHat PDF
Advanced Data Structures And Algorithms Roadmap By ScholarHat PDF
Scholarhat
 

Similar to Data structures; arrays By ZAK (20)

arrays.docx
arrays.docxarrays.docx
arrays.docx
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptx
 
DSA-Lecture-05
DSA-Lecture-05DSA-Lecture-05
DSA-Lecture-05
 
Data structures "1" (Lectures 2015-2016)
Data structures "1" (Lectures 2015-2016) Data structures "1" (Lectures 2015-2016)
Data structures "1" (Lectures 2015-2016)
 
September 9 2008
September 9 2008September 9 2008
September 9 2008
 
Mca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structureMca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structure
 
Arrays
ArraysArrays
Arrays
 
Bsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structureBsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structure
 
C programming session 04
C programming session 04C programming session 04
C programming session 04
 
Chapter 4 (Part I) - Array and Strings.pdf
Chapter 4 (Part I) - Array and Strings.pdfChapter 4 (Part I) - Array and Strings.pdf
Chapter 4 (Part I) - Array and Strings.pdf
 
Bca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structureBca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structure
 
Data Structures And Algorithms Roadmap for Beginners By ScholarHat PDF
Data Structures And Algorithms Roadmap for Beginners  By ScholarHat PDFData Structures And Algorithms Roadmap for Beginners  By ScholarHat PDF
Data Structures And Algorithms Roadmap for Beginners By ScholarHat PDF
 
UNIT-5_Array in c_part1.pptx
UNIT-5_Array in c_part1.pptxUNIT-5_Array in c_part1.pptx
UNIT-5_Array in c_part1.pptx
 
Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional array
 
2D Array
2D Array 2D Array
2D Array
 
M v bramhananda reddy dsa complete notes
M v bramhananda reddy dsa complete notesM v bramhananda reddy dsa complete notes
M v bramhananda reddy dsa complete notes
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
 
Array
ArrayArray
Array
 
Array
ArrayArray
Array
 
Advanced Data Structures And Algorithms Roadmap By ScholarHat PDF
Advanced Data Structures And Algorithms Roadmap By ScholarHat PDFAdvanced Data Structures And Algorithms Roadmap By ScholarHat PDF
Advanced Data Structures And Algorithms Roadmap By ScholarHat PDF
 

More from Tabsheer Hasan

Lab Network Settings And Testing
Lab Network Settings And TestingLab Network Settings And Testing
Lab Network Settings And Testing
Tabsheer Hasan
 
How to train cortana to respond to your voice
How to train cortana to respond to your voiceHow to train cortana to respond to your voice
How to train cortana to respond to your voice
Tabsheer Hasan
 
How to turn on hey cortana on windows 10
How to turn on hey cortana on windows 10How to turn on hey cortana on windows 10
How to turn on hey cortana on windows 10
Tabsheer Hasan
 
How to pin cortana to your taskbar on
How to pin cortana to your taskbar on How to pin cortana to your taskbar on
How to pin cortana to your taskbar on
Tabsheer Hasan
 
Introduction To Computer
Introduction To ComputerIntroduction To Computer
Introduction To Computer
Tabsheer Hasan
 
How to set up cortana on windows 10
How to set up cortana on windows 10How to set up cortana on windows 10
How to set up cortana on windows 10
Tabsheer Hasan
 
2210 s15 qp_ms_er_12
2210 s15 qp_ms_er_122210 s15 qp_ms_er_12
2210 s15 qp_ms_er_12
Tabsheer Hasan
 
Databases By ZAK
Databases By ZAKDatabases By ZAK
Databases By ZAK
Tabsheer Hasan
 
Programming concepts By ZAK
Programming concepts By ZAKProgramming concepts By ZAK
Programming concepts By ZAK
Tabsheer Hasan
 
Pseudocode By ZAK
Pseudocode By ZAKPseudocode By ZAK
Pseudocode By ZAK
Tabsheer Hasan
 
problem solving and design By ZAK
problem solving and design By ZAKproblem solving and design By ZAK
problem solving and design By ZAK
Tabsheer Hasan
 
Ethics By ZAK
Ethics By ZAKEthics By ZAK
Ethics By ZAK
Tabsheer Hasan
 
security By ZAK
security By ZAKsecurity By ZAK
security By ZAK
Tabsheer Hasan
 
operating systems By ZAK
operating systems By ZAKoperating systems By ZAK
operating systems By ZAK
Tabsheer Hasan
 
memory, storage devices and media By ZAK
memory, storage devices and media By ZAKmemory, storage devices and media By ZAK
memory, storage devices and media By ZAK
Tabsheer Hasan
 
input devices By ZAK
input devices By ZAKinput devices By ZAK
input devices By ZAK
Tabsheer Hasan
 
1.3.2 computer architecture and the fetch execute cycle By ZAK
1.3.2 computer architecture and the fetch execute cycle By ZAK1.3.2 computer architecture and the fetch execute cycle By ZAK
1.3.2 computer architecture and the fetch execute cycle By ZAK
Tabsheer Hasan
 
computer architecture and the fetch execute cycle By ZAK
computer architecture and the fetch execute cycle By ZAKcomputer architecture and the fetch execute cycle By ZAK
computer architecture and the fetch execute cycle By ZAK
Tabsheer Hasan
 
logic gates By ZAK
logic gates By ZAKlogic gates By ZAK
logic gates By ZAK
Tabsheer Hasan
 
internet principles of operation By ZAK
internet principles of operation By ZAKinternet principles of operation By ZAK
internet principles of operation By ZAK
Tabsheer Hasan
 

More from Tabsheer Hasan (20)

Lab Network Settings And Testing
Lab Network Settings And TestingLab Network Settings And Testing
Lab Network Settings And Testing
 
How to train cortana to respond to your voice
How to train cortana to respond to your voiceHow to train cortana to respond to your voice
How to train cortana to respond to your voice
 
How to turn on hey cortana on windows 10
How to turn on hey cortana on windows 10How to turn on hey cortana on windows 10
How to turn on hey cortana on windows 10
 
How to pin cortana to your taskbar on
How to pin cortana to your taskbar on How to pin cortana to your taskbar on
How to pin cortana to your taskbar on
 
Introduction To Computer
Introduction To ComputerIntroduction To Computer
Introduction To Computer
 
How to set up cortana on windows 10
How to set up cortana on windows 10How to set up cortana on windows 10
How to set up cortana on windows 10
 
2210 s15 qp_ms_er_12
2210 s15 qp_ms_er_122210 s15 qp_ms_er_12
2210 s15 qp_ms_er_12
 
Databases By ZAK
Databases By ZAKDatabases By ZAK
Databases By ZAK
 
Programming concepts By ZAK
Programming concepts By ZAKProgramming concepts By ZAK
Programming concepts By ZAK
 
Pseudocode By ZAK
Pseudocode By ZAKPseudocode By ZAK
Pseudocode By ZAK
 
problem solving and design By ZAK
problem solving and design By ZAKproblem solving and design By ZAK
problem solving and design By ZAK
 
Ethics By ZAK
Ethics By ZAKEthics By ZAK
Ethics By ZAK
 
security By ZAK
security By ZAKsecurity By ZAK
security By ZAK
 
operating systems By ZAK
operating systems By ZAKoperating systems By ZAK
operating systems By ZAK
 
memory, storage devices and media By ZAK
memory, storage devices and media By ZAKmemory, storage devices and media By ZAK
memory, storage devices and media By ZAK
 
input devices By ZAK
input devices By ZAKinput devices By ZAK
input devices By ZAK
 
1.3.2 computer architecture and the fetch execute cycle By ZAK
1.3.2 computer architecture and the fetch execute cycle By ZAK1.3.2 computer architecture and the fetch execute cycle By ZAK
1.3.2 computer architecture and the fetch execute cycle By ZAK
 
computer architecture and the fetch execute cycle By ZAK
computer architecture and the fetch execute cycle By ZAKcomputer architecture and the fetch execute cycle By ZAK
computer architecture and the fetch execute cycle By ZAK
 
logic gates By ZAK
logic gates By ZAKlogic gates By ZAK
logic gates By ZAK
 
internet principles of operation By ZAK
internet principles of operation By ZAKinternet principles of operation By ZAK
internet principles of operation By ZAK
 

Recently uploaded

ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 

Recently uploaded (20)

ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 

Data structures; arrays By ZAK

  • 1. Page 1 of 3 2.2 Programming 2.2.2 Data structures; arrays Define and use arrays (one- and two-dimensional) for solving simple problems (this should include initializing arrays, reading data into arrays and performing a simple serial search on a one-dimensional array) A data structure is a collection of different data items that are stored together in a clearly defined way. Two common data structures are arrays and records. Array An array is a data structure, which allows a set of items of identical data type to be stored together using the same identifier name. Arrays are declared in a similar way to standard variables, except that the array size and dimensions are included. For example, the following declares an array that reserves five locations in memory and labels these as ‘Names’: DIM Names(4) As String The five individual locations are Names(0), Names(1), Names(2), Names(3), Names(4). Each data item is called an element of the array. To reference a particular element a programmer must use the appropriate index. For example, the following statement assigns data to the 5th element: Names(4) = “John” Arrays simplify the processing of similar data. An algorithm for getting five names from the user and storing them in the array Names is shown below: Dim Names(4) As String Dim name As String For i=0 to 4 Input name Names(i)=name Next i
  • 2. Page 2 of 3 2.2 Programming 2.2.2 Data structures; arrays One-dimensional arrays A one-dimensional array is a data structure in which the array is declared using a single index and can be visually represented as a list. The following diagram shows the visual representation of the array Names(4):
  • 3. Page 3 of 3 2.2 Programming 2.2.2 Data structures; arrays Array Questions: Question 01: Input and store the names and marks for 30 students who have sat three computer science tests. Test 1 is out of 20 marks, Test 2 is out of 25 marks, Test 3 is out of 35 marks. You must store the names in a one-dimensional array and the marks and total score for each student in one-dimensional arrays. All the marks must be validated on entry and any invalid marks rejected. You may assume that the students’ names are unique. Question 02: Calculate and store the total score for each student and calculate the average score for the whole class. Output each student’s name followed by their total score, and then output the average score for the class. Question 03: Select the student with the highest score and output their name and score. Your program must include appropriate prompts for the entry of data. Error messages and other output need to be set out clearly and understandably. All variables, constants and other identifiers must have meaningful names. Each task must be fully tested. Question 04: Write a pseudocode using array, asks user to input 10 numbers, then calculates the average of those numbers. Loop is used in this problem. Question 05: Write a pseudocode to swap first and last element of an integer 1-d array. Question 06: Write a pseudocode to find the largest and smallest element of an array.