Arrays

5,133 views

Published on

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,133
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
212
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Arrays

  1. 1. Introduction to Arrays Classification of Arrays Arrays Abhineet Anand Computer Science and Engg. DepartmentUniversity of Petrolium and Energy Studies, Dehradun November 27, 2012 Abhineet Anand Arrays
  2. 2. Introduction Introduction to Arrays Arrays Classification of Arrays Arrays: DefinitionIntroduction Variables Variables are the symbolic representation of memory location. The variables are the names given to identify the specific program elements and also one of the identifiers. They are used to denote constant, functions, arrays, fields of structure, name of files etc. Abhineet Anand Arrays
  3. 3. Introduction Introduction to Arrays Arrays Classification of Arrays Arrays: DefinitionArrays Arrays A normal variable can hold only one value. Sometime it is required to use a single name for group of data items. Such a construct of programming language which stores and organizes a set of data item is called data structure. Different types of data structure are arrays, stacks, queues, linked lists, structures, trees and files etc. Abhineet Anand Arrays
  4. 4. Introduction Introduction to Arrays Arrays Classification of Arrays Arrays: DefinitionDefinition An array can be defined as an ordered list of homogenous data elements. May be of type int, float, char or double. All these elements are stored in consecutive memory locations. An array is described by a single name or an identifier and each element in an array is referenced by a subscript (or an index) enclosed in a pair of square brackets. Abhineet Anand Arrays
  5. 5. Classification of Arrays Introduction to Arrays One-Dimensional Array Classification of Arrays Multidimensional ArraysClassification of Arrays Arrays are classified into two types: One-dimensional Multi-dimensional The dimensionality of an array is determined by the number of subscript present in the given array. If there is only one subscript, then it is called a one-dimensional array. Array must be declared before it appear in C Program. Abhineet Anand Arrays
  6. 6. Classification of Arrays Introduction to Arrays One-Dimensional Array Classification of Arrays Multidimensional ArraysOne-Dimensional Array Linear list of fixed number of data items of the same type. Syntax of declaring a one - dimensional array: where, arrayname : Name of array, size: Number of elements of type datatype and datatype: Any basic data type or user defined data type Example: int list[10]; float xyz[5]; Abhineet Anand Arrays
  7. 7. Classification of Arrays Introduction to Arrays One-Dimensional Array Classification of Arrays Multidimensional ArraysExample of One Dimensional Array Abhineet Anand Arrays
  8. 8. Classification of Arrays Introduction to Arrays One-Dimensional Array Classification of Arrays Multidimensional ArraysOutput of the Program Abhineet Anand Arrays
  9. 9. Classification of Arrays Introduction to Arrays One-Dimensional Array Classification of Arrays Multidimensional ArraysDo Some Exercise Write a C program to accept two inetger arrays and find the sum of the corresponding elements of these two arrays. Write a C program to compute the sum of even and odd numbers stored in an array of N inetgers. And print the same. Write a C program to arrange a set of floating-point numbers in an asending order and print them. Abhineet Anand Arrays
  10. 10. Classification of Arrays Introduction to Arrays One-Dimensional Array Classification of Arrays Multidimensional ArraysMultidimensional Arrays If the number of subscripts is more than one then such arrays are called multi-dimensional arrays. Dimension is determined by the number of pairs of square brackets placed after the array name. Example: array1[ ] -> One-Dimensional Array array2[ ][ ] -> Two-dimensional Array array3[ ] [ ] [ ] -> Three-dimensional Array Abhineet Anand Arrays
  11. 11. Classification of Arrays Introduction to Arrays One-Dimensional Array Classification of Arrays Multidimensional ArraysTwo-dimensional Array It is Ordered table of homogeneous elements. It is referred to as a matrix of some rows and columns. It is also called as a two-subscripted variables. Where, datatype− > basic data type, arrayname− > name of a two-dimensional array, rows->hnumbers of elements to be processed under subscript 1. columns -> numbers of elements to be processed under subscript 2. Abhineet Anand Arrays
  12. 12. Classification of Arrays Introduction to Arrays One-Dimensional Array Classification of Arrays Multidimensional ArraysExample of Two Dimensional Array Abhineet Anand Arrays
  13. 13. Introduction to ArraysClassification of Arrays THANK YOU Abhineet Anand Arrays

×