CM304
CM304
ANDHRA PRADESH
Name of the faculty : P. Alimullah Khan.
Designation : Lecturer
Branch : Computer Engineering
Institute : V.K.R & V.N.B Polytechnic, Gudivada
Year/Semester : III Semester
Subject : UNIX & C.
Subject Code : CM-304.
Topic : Understand basics of Arrays.
Duration : 50 Min
Sub Topic : Access and initialization of array .
Teaching Aids : Diagram and animations,ppt.
CM304.58TO59 1
Objective
CM304.58TO59 2
Recap
CM304.58TO59 3
Accessing array elements
A particular array can be accessed by
specifying appropriate subscript or index
number with the array name.
To assign a value from out side the array by
using assignment operator.
CM304.58TO59 4
Example of accessing array elements
Example1
matrix [0][3]=1;
the value ‘1’ is assigned to the element
at first row and fourth column.
0 1 2
0 3
CM304.58TO59 5
Array initialization
CM304.58TO59 6
General form of initialization of array
Datatype variable name [size]={list of values};
Example:
int a[5]={2,3,5,6,7};
CM304.58TO59 7
General form of initialization of array
CM304.58TO59 8
Example of array initialization
CM304.58TO59 9
Simple program using initialization of arrays
#include<stdio.h> List of
initialized
main( ) values
Output:
{ The initialized
int marks[5]={45,55,50,75,60}; marks are
45
int i; 55
50
for(i =0;i<5;i++) 75
{ 60
CM304.58TO59 10
Summary
CM304.58TO59 11
Quiz
CM304.58TO59 12
Quiz
CM304.58TO59 13
Quiz
CM304.58TO59 14
Quiz
CM304.58TO59 15
Quiz
CM304.58TO59 16
Quiz
CM304.58TO59 17
Quiz
CM304.58TO59 18
Quiz
CM304.58TO59 19
Quiz
CM304.58TO59 20
Quiz
CM304.58TO59 21
Quiz
CM304.58TO59 22
Quiz
CM304.58TO59 23
Quiz
CM304.58TO59 24
Quiz
CM304.58TO59 25
Frequently Asked Questions
CM304.58TO59 26