CodesJava

Easy learning with example program codes

C Array to Function


Arguments are the variables, inside the parentheses, after the function name which is used to pass informations to functions. Beside passing variables and pointers, arrays can also be passed as a function parameter or argument.

Syntax:

Return_type functionName (Data_type array Name[])

{

    code to be executed;

}

Example:

#include<stdio.h>  
 
int maximum(int a[],int size)
{    
int max = a[0];    
int i=0;    
for(i=1;i<size;i++)
{
if(max < a[i])  
max = a[i];    
}  
return max;    
}
 
void main()
{ 	 
int i=0,max=0;    
int array[] ={9,52,77,635,889,679,6,54,78,34};
 
printf ("List of Numbers:\n");
for(i=0;i<10;i++)
{
printf ("%d",array[i]);
printf ("\n");
}
 
max = maximum(array,10);
printf("\nLargest Number is: %d",max);    
}

Output

List of Numbers:
9
52
77
635
889
679
6
54
78
34
 
Largest Number is: 889
Posted in C   
Sign Up/ Sign In
Ask a Question


Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at hr@codesjava.com.

Development

We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on hr@codesjava.com.

Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki