Introducing Arrays in C. PURPOSE: Storing multiple data items under the same name Example:  Salaries of 10 employees  Percentage of marks of my dear.

Slides:



Advertisements
Similar presentations
UNIT IV.
Advertisements

Copyright © 2002 Pearson Education, Inc. Slide 1.
Chapter 8: Arrays.
1 Arrays An array is a special kind of object that is used to store a collection of data. The data stored in an array must all be of the same type, whether.
Programming In C++ Spring Semester 2013 Lecture 6 Programming In C++, Lecture 6 By Umer Rana.
Introduction to Arrays Chapter What is an array? An array is an ordered collection that stores many elements of the same type within one variable.
Structure.
Single Variable and a Lot of Variables The declaration int k; float f; reserve one single integer variable called k and one single floating point variable.
An Array A sequence of elements of a particular type Each element in the array has an index which gives its position in the sequence An array is declared.
Arrays I Savitch Chapter 6.1: Introduction to Arrays.
Structures. An array allows us to store a collection of variables However, the variables must be of the same type to be stored in an array E.g. if we.
Objects and Collections of Objects COMP53 Aug
1 Array Knowledge Understand the execute technique of array Skill Can write application program using one and two dimensional array.
©2004 Brooks/Cole Chapter 8 Arrays. Figures ©2004 Brooks/Cole CS 119: Intro to JavaFall 2005 Sometimes we have lists of data values that all need to be.
Lecture 15 Arrays: Part 1 COMP1681 / SE15 Introduction to Programming.
© The McGraw-Hill Companies, 2006 Chapter 5 Arrays.
Arrays.
C Programming Lecture 14 Arrays. What is an Array? b An array is a sequence of data items that are: all of the same typeall of the same type –a sequence.
Lilian Blot CORE ELEMENTS COLLECTIONS & REPETITION Lecture 4 Autumn 2014 TPOP 1.
03/16/ What is an Array?... An array is an object that stores list of items. Each slot of an array holds an individual element. Characteristics.
Structs. Structures We already know that arrays are many variables of the same type grouped together under the same name. Structures are like arrays except.
Program structure Four different storage-class specifications: –Automatic (auto): local to a function, normally declared variables are automatic. Does.
Arrays in C++ Numeric Character. Structured Data Type A structured data type is a type that stores a collection of individual components with one variable.
1 DATA STRUCTURES: LISTS. 2 LISTS ARE USED TO WORK WITH A GROUP OF VALUES IN AN ORGANIZED MANNER. A SERIES OF MEMORY LOCATIONS CAN BE DIRECTLY REFERENCED.
Introduction to Arrays in Java Corresponds with Chapter 6 of textbook.
JAVA Array 8-1 Outline  Extra material  Array of Objects  enhanced-for Loop  Class Array  Passing Arrays as Arguments to Methods  Returning Arrays.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper.
Computer Science 210 Computer Organization Arrays.
UNIT II. -set of homogeneous data items. Eg: int arrays can hold only integers and char arrays can only hold characters. Arrays have a type, name, and.
Review of ICS 102. Lecture Objectives To review the major topics covered in ICS 102 course Refresh the memory and get ready for the new adventure of ICS.
1 Mr. Muhammad Hanif Lecturer Information Technology MBBS Campus Dadu University of SIndh.
Arrays. An array is a group of like-typed variables that are referred to by a common name. Arrays of any type can be created and may have one or more.
CHAPTER 7 arrays I NTRODUCTION T O C OMPUTER P ROGRAMMING (CSC425)
Foundation Studies Course M.Montebello Arrays Foundation Studies Course.
Array, Structure and Union
Python Arrays. An array is a variable that stores a collection of things, like a list. For example a list of peoples names. We can access the different.
1 C Language Structures. 2 Topics Concept of a structure Concept of a structure Structures in c Structures in c Structure declaration Structure declaration.
Struct 1. Definition: Using struct to define a storage containing different types. For example it can contain int, char, float and array at the same time.
APS105 Lists. Structures Arrays allow a collection of elements –All of the same type How to collect elements of different types? –Structures; in C: struct.
Arrays. Related data items Collection of the same types of data. Static entity – Same size throughout program.
Structured Programming Approach Module VIII - Additional C Data Types Structures Prof: Muhammed Salman Shamsi.
1 Chapter 12 Arrays. 2 C++ Data Types structured array struct union class address pointer reference simple integral enum char short int long bool floating.
Review Sorting algorithms Selection Sort Insertion Sort Bubble Sort Merge Sort Quick Sort.
Chapter 8 Arrays. A First Book of ANSI C, Fourth Edition2 Introduction Atomic variable: variable whose value cannot be further subdivided into a built-in.
Arrays.
Computer Programming for Engineers
Arrays. Topics to be Covered... Arrays ◦ Declaration ◦ Assigning values ◦ Array manipulation using loops Multi-dimensional arrays ◦ 2D arrays ◦ Declaration.
Module 1: Array ITEI222 - Advance Programming Language.
In C programming, one of the frequently arising problem is to handle similar types of data. For example: If the user want to store marks of 100 students.
MULTI-DIMENSIONAL ARRAYS 1. Multi-dimensional Arrays The types of arrays discussed so far are all linear arrays. That is, they all dealt with a single.
Arrays (Chapter 5)‏ Definition Applications One-Dimensional –Declaration –Initialization –Use Multidimensional.
1 CSC103: Introduction to Computer and Programming Lecture No 17.
CS 1430: Programming in C++.
Lecture #15 ARRAYS By Shahid Naseem (Lecturer). 2 ARRAYS DEFINITION An array is a sequence of objects of same data type. The objects in an array are also.
1 C++ Data Types structured array struct union class address pointer reference simple integral enum char short int long bool floating float double long.
1 Programming in C++ Dale/Weems/Headington Chapter 11 One-Dimensional Arrays.
Strings C supports strings using one-dimensional character arrays. A string is defined as a null-terminated character array. In C, a null is 0. You must.
Some Assignments  Write a program which prints the following information about at least 5 persons: NAME MAIL-ID EMPLOYEE-CODE PHONE Eg. Umesh
Arrays in C The c language provides a capability that enables the user to design a set of similar data types called array. Pointers and arrays are.
Module 2 Arrays and strings – example programs.
ARRAYS An array is a sequence of data item of homogeneous value(same type). Arrays are of two types: 1. One-dimensional arrays 2. Multi-Dimensional arrays.
C++ Arrays.
CS-161 Computer Programming Lecture 14: Arrays I
Declaration, assignment & accessing
Lecture 12 Oct 16, 02.
By Yogesh Neopaney Assistant Professor Department of Computer Science
Structures In C Programming By Rajanikanth B.
Arrays Prepared By Paritosh Srivastava PGT (CS) KV NHPC Banbasa.
Visit for more Learning Resources
Presentation transcript:

Introducing Arrays in C

PURPOSE: Storing multiple data items under the same name Example:  Salaries of 10 employees  Percentage of marks of my dear 63 students Note: The data items in an array must be of the same data type ( int,float,char )

Array -definition Array is a sequenced collection of related data items that share a common name

Declaring an array variable int marks[63] int salary[10] float temperature[100] Note: static keyword can be used to intialise the values to 0 ie static float temperature [ ]

Representation of Arrays in memmory salary[10]

Accessing Elements of an array We make use of the index value to access the elements of an array ie salary[0]- Represents 1 st element of an array salary[1]- Represents 2 nd element of an array salary[6]- salary[9]-

Array initialisation int marks[5]={30,23,44,45,32} float temp[ ]={22.5, 54.6, 71.5, 8.7}

Entering data into an array for(i=0;i<63;i++) { printf(“Enter marks”); scanf(“%d”,&marks[i]); }

Reading data from an Array for(i=0;i<63;i++) { printf(“%d”,marks[i]); }

PROBLEM 1: Write a program to enter the marks obtained by 5 students in a test into an array and then display it

PROBLEM 2: Write a program to enter the marks obtained by 63 students in a test into an array and then find the highest mark in the list

PROBLEM 3: Write a program to find the average marks obtained by class of 63 students in a test