Skip to main content

passing array to a function by declaring array as parameter in function


#include <stdio.h>
int fun1(int array[])
{
for (int i = 0; i < 4; ++i)
{
printf("The value of %d is %d \n",i,array[i]);

}
array[0]=89;/*if we change the formal(parameter) value effect will be reflected in
actual(parameter) value as it passes the address of array*/

}
int main ()
{
int arr[]={2,4,6,8};
printf("The value of index 0 is %d\n",arr[0]);
fun1(arr);
printf("The value of index 0 is %d\n",arr[0]);
return 0;
}

Comments

Popular posts from this blog

example of typecasting in c

/*Type Casting in C Typecasting allows us to convert one data type into other. */ //simple example to cast int value into the float. #include <stdio.h>    int   main (){   float   f = ( float ) 9 / 4 ;     printf ( "f : %f \n " ,  f  );     return   0 ;   }