Download presentation
Presentation is loading. Please wait.
Published byAmice Hunt Modified over 9 years ago
1
Introducing Arrays in C
2
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 )
3
Array -definition Array is a sequenced collection of related data items that share a common name
4
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 [ ]
5
Representation of Arrays in memmory salary[10]
6
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]-
7
Array initialisation int marks[5]={30,23,44,45,32} float temp[ ]={22.5, 54.6, 71.5, 8.7}
8
Entering data into an array for(i=0;i<63;i++) { printf(“Enter marks”); scanf(“%d”,&marks[i]); }
9
Reading data from an Array for(i=0;i<63;i++) { printf(“%d”,marks[i]); }
10
PROBLEM 1: Write a program to enter the marks obtained by 5 students in a test into an array and then display it
11
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
12
PROBLEM 3: Write a program to find the average marks obtained by class of 63 students in a test
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.