SlideShare ist ein Scribd-Unternehmen logo
1 von 11
Presented By:
Presented To:
One Dimensional Array
♣Structured collection of components.
♣Structure given a single name.
♣Individual elements accessed by index indicating
relative position in collection.
♣Type of elements stored in an array can be “just
about” anything.
♣Index of an array must be an integer.
Declaring Arrays
¤ Declaration examples:
int[] counts;
double[] scores;
String[] studentNames;
¤Syntax:
Data type Array name [constant]
Array Allocation
Arrays are allocated using the Java new operator
The syntax is:
new type[size];
Examples:
counts = new int[10];
scores = new double[15];
studentNames = new String[10];
Array Organization
counts
Each box is an int variable
The numbers on top are each variable’s
subscript or index
An array of size 10 has subscripts 0 to 9
0 1 2 3 4 5 6 7 8 9
Array Initialization
• Arrays can be initialized by giving a list of their elements
• If your list contains n elements the subscripts will range
from 0 to n – 1
• Do not need to allocate the array explicitly after it is
initialized
• Example:
int [] primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};
Arrays of Objects
•Arrays of objects are declared in the same manner
as arrays of primitive variables
•Assuming that a class Student was declared
elsewhere a client application could declare and
allocate an array of 10 students using
Student[ ] students;
students = new Student[10];
#include<stdio.h>
#include<string.h>
int main()
{
char s1[80],s2[80];
gets (s1);
gets (s2);
puts(s1);
puts(s2);
printf("length:%d %dn",strlen(s1),strlen(s2));
return 0;
}
Example of 1D ARRAY
#include <stdio.h>
int main()
{
int i, n;
float
a[100],sum=0,sum_pos=0,sum_neg=0,avg;
printf("enter the value:");
scanf("%d",&n);
for(i=0;i<n; i++)
{ scanf("%f",&a[i]);
}
for(i=0;i<n; i++)
{
if(a[i]>0)
sum_pos=sum_pos+a[i];
}
for(i=0;i<n; i++)
{
if(a[i]<0)
sum_neg=sum_neg+a[i];
}
sum=sum_pos+sum_neg;
avg=sum/n;
printf("%fn",sum);
printf("%fn",avg);
return 0;
}
Example of 1D ARRAY
Thank
you

Weitere ähnliche Inhalte

Was ist angesagt? (20)

PPt. on An _Array in C
PPt. on An _Array in CPPt. on An _Array in C
PPt. on An _Array in C
 
Java arrays
Java arraysJava arrays
Java arrays
 
Array in c
Array in cArray in c
Array in c
 
Arrays in java
Arrays in javaArrays in java
Arrays in java
 
Presentation of array
Presentation of arrayPresentation of array
Presentation of array
 
Learn ActionScript programming myassignmenthelp.net
Learn ActionScript programming myassignmenthelp.netLearn ActionScript programming myassignmenthelp.net
Learn ActionScript programming myassignmenthelp.net
 
Array
ArrayArray
Array
 
2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers
 
Arrays In C
Arrays In CArrays In C
Arrays In C
 
Arrays
ArraysArrays
Arrays
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
C
CC
C
 
Chapter 6 java
Chapter 6 javaChapter 6 java
Chapter 6 java
 
OOPs with java
OOPs with javaOOPs with java
OOPs with java
 
C++ Arrays
C++ ArraysC++ Arrays
C++ Arrays
 
Object Class
Object ClassObject Class
Object Class
 
Cis166 Final Review C#
Cis166 Final Review C#Cis166 Final Review C#
Cis166 Final Review C#
 
Arrays in java
Arrays in javaArrays in java
Arrays in java
 
R DATA STRUCTURES 1
R DATA STRUCTURES 1R DATA STRUCTURES 1
R DATA STRUCTURES 1
 
Flash workshop Day Three
Flash workshop Day ThreeFlash workshop Day Three
Flash workshop Day Three
 

Andere mochten auch

Array in c language
Array in c languageArray in c language
Array in c languagehome
 
Selection Control Structures
Selection Control StructuresSelection Control Structures
Selection Control StructuresPRN USM
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array pptsandhya yadav
 
Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)EngineerBabu
 

Andere mochten auch (8)

Ch5 array nota
Ch5 array notaCh5 array nota
Ch5 array nota
 
Array in c language
Array in c languageArray in c language
Array in c language
 
Selection Control Structures
Selection Control StructuresSelection Control Structures
Selection Control Structures
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array ppt
 
Arrays In C++
Arrays In C++Arrays In C++
Arrays In C++
 
Array in C
Array in CArray in C
Array in C
 
Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)
 
Arrays
ArraysArrays
Arrays
 

Ähnlich wie One Dimentional Array (20)

Array.ppt
Array.pptArray.ppt
Array.ppt
 
array.ppt
array.pptarray.ppt
array.ppt
 
Array
ArrayArray
Array
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
Arrays
ArraysArrays
Arrays
 
Array and its types and it's implemented programming Final.pdf
Array and its types and it's implemented programming Final.pdfArray and its types and it's implemented programming Final.pdf
Array and its types and it's implemented programming Final.pdf
 
Arrays in C Programming
Arrays in C ProgrammingArrays in C Programming
Arrays in C Programming
 
ch11.ppt
ch11.pptch11.ppt
ch11.ppt
 
Array in c#
Array in c#Array in c#
Array in c#
 
Arrays in JAVA.ppt
Arrays in JAVA.pptArrays in JAVA.ppt
Arrays in JAVA.ppt
 
Arrays
ArraysArrays
Arrays
 
Arrays
ArraysArrays
Arrays
 
Array in-c
Array in-cArray in-c
Array in-c
 
Array in c language
Array in c language Array in c language
Array in c language
 
Basics of array.pptx
Basics of array.pptxBasics of array.pptx
Basics of array.pptx
 
Programming fundamentals week 12.pptx
Programming fundamentals week 12.pptxProgramming fundamentals week 12.pptx
Programming fundamentals week 12.pptx
 
Arrays.pptx
Arrays.pptxArrays.pptx
Arrays.pptx
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
 
2 arrays
2   arrays2   arrays
2 arrays
 
Arrays
ArraysArrays
Arrays
 

Mehr von Sonya Akter Rupa

Synchronous Counter in Digital Logic Device
Synchronous Counter in Digital Logic DeviceSynchronous Counter in Digital Logic Device
Synchronous Counter in Digital Logic DeviceSonya Akter Rupa
 
Method Overloading in Java
Method Overloading in JavaMethod Overloading in Java
Method Overloading in JavaSonya Akter Rupa
 
Switch Case in C Programming
Switch Case in C ProgrammingSwitch Case in C Programming
Switch Case in C ProgrammingSonya Akter Rupa
 
The population is resource or burden for Bangladesh
The population is resource or burden for BangladeshThe population is resource or burden for Bangladesh
The population is resource or burden for BangladeshSonya Akter Rupa
 
Spherical Polar Coordinate System- physics II
Spherical Polar Coordinate System- physics IISpherical Polar Coordinate System- physics II
Spherical Polar Coordinate System- physics IISonya Akter Rupa
 

Mehr von Sonya Akter Rupa (9)

Synchronous Counter in Digital Logic Device
Synchronous Counter in Digital Logic DeviceSynchronous Counter in Digital Logic Device
Synchronous Counter in Digital Logic Device
 
Method Overloading in Java
Method Overloading in JavaMethod Overloading in Java
Method Overloading in Java
 
Enviremental Pollution
Enviremental PollutionEnviremental Pollution
Enviremental Pollution
 
Switch Case in C Programming
Switch Case in C ProgrammingSwitch Case in C Programming
Switch Case in C Programming
 
File in C Programming
File in C ProgrammingFile in C Programming
File in C Programming
 
Pointer in C
Pointer in CPointer in C
Pointer in C
 
Two Dimentional Array
Two Dimentional ArrayTwo Dimentional Array
Two Dimentional Array
 
The population is resource or burden for Bangladesh
The population is resource or burden for BangladeshThe population is resource or burden for Bangladesh
The population is resource or burden for Bangladesh
 
Spherical Polar Coordinate System- physics II
Spherical Polar Coordinate System- physics IISpherical Polar Coordinate System- physics II
Spherical Polar Coordinate System- physics II
 

Kürzlich hochgeladen

The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01KreezheaRecto
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...tanu pandey
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 

Kürzlich hochgeladen (20)

The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 

One Dimentional Array

  • 1.
  • 3. One Dimensional Array ♣Structured collection of components. ♣Structure given a single name. ♣Individual elements accessed by index indicating relative position in collection. ♣Type of elements stored in an array can be “just about” anything. ♣Index of an array must be an integer.
  • 4. Declaring Arrays ¤ Declaration examples: int[] counts; double[] scores; String[] studentNames; ¤Syntax: Data type Array name [constant]
  • 5. Array Allocation Arrays are allocated using the Java new operator The syntax is: new type[size]; Examples: counts = new int[10]; scores = new double[15]; studentNames = new String[10];
  • 6. Array Organization counts Each box is an int variable The numbers on top are each variable’s subscript or index An array of size 10 has subscripts 0 to 9 0 1 2 3 4 5 6 7 8 9
  • 7. Array Initialization • Arrays can be initialized by giving a list of their elements • If your list contains n elements the subscripts will range from 0 to n – 1 • Do not need to allocate the array explicitly after it is initialized • Example: int [] primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};
  • 8. Arrays of Objects •Arrays of objects are declared in the same manner as arrays of primitive variables •Assuming that a class Student was declared elsewhere a client application could declare and allocate an array of 10 students using Student[ ] students; students = new Student[10];
  • 9. #include<stdio.h> #include<string.h> int main() { char s1[80],s2[80]; gets (s1); gets (s2); puts(s1); puts(s2); printf("length:%d %dn",strlen(s1),strlen(s2)); return 0; } Example of 1D ARRAY
  • 10. #include <stdio.h> int main() { int i, n; float a[100],sum=0,sum_pos=0,sum_neg=0,avg; printf("enter the value:"); scanf("%d",&n); for(i=0;i<n; i++) { scanf("%f",&a[i]); } for(i=0;i<n; i++) { if(a[i]>0) sum_pos=sum_pos+a[i]; } for(i=0;i<n; i++) { if(a[i]<0) sum_neg=sum_neg+a[i]; } sum=sum_pos+sum_neg; avg=sum/n; printf("%fn",sum); printf("%fn",avg); return 0; } Example of 1D ARRAY