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 : Passing array elements as arguments.
Teaching Aids : Diagram and animations.
CM304.60 1
Objective
CM304.60 2
Recap
Initialization of an array.
CM304.60 3
Passing Arrays as argument to functions
We can pass
CM304.60 4
Passing array elements as arguments
CM304.60 5
Simple program using passing arrays
elements as arguments
#include<stdio.h>
int tol(int)
main()
{
int i, a[5];
printf (“enter the elements”);
for (i=0;i<5;i++)
scanf (“%d”, &a[i]);
printf (“the array elements”);
CM304.60 6
Simple program using passing arrays
elements as arguments Contd..
for (i=0;i<5;i++)
printf (“%d”, a[i]);
functio for (i=0;i<5;i++)
n printf (“%d”, tol(a[i]));
}
int tol( int m1);
{ Argume
int m2; nt
m2=m1+m1+m1;
return(m2);
}
CM304.60 7
Passing an arrays elements to functions
main ( ) tol
m1
a[i]
m2
Fig 60.1
CM304.60 8
Passing an arrays elements to functions
CM304.60 9
Passing an arrays elements to functions
#include < stdio.h>
main( )
{
int grade[50];
.
first (grade);
.
}
int first( int f_ grade[])
{
.
.} CM304.60 10
Passing an arrays elements to functions
arguments to a function .
CM304.60 11
Passing an arrays elements to functions
CM304.60 12
Summary
CM304.60 13
Quiz
c) none.
CM304.60 14
Quiz
c) none.
CM304.60 15
Quiz
CM304.60 16
Quiz
CM304.60 17
Frequently Asked Questions