-->
By

Array Variable (declared as Global) and changing the value inside a function -C programming 


#include<stdio.h>

int a[3] ={10,15,20}; // declaring array variable as global
int test_function(); // a function to change the array varriable value in side the function
int main()
{

int i,j;

for(i=0;i<3; i++)
printf("Inside the main function i = %d\n",a[i]);

test_function();
printf("\n\n");
for(i=0;i<3; i++)
printf("Inside the test function i = %d\n",a[i]);
return 0;
}

int test_function()
{
a[0] = 18;
a[1] = 100;
a[2] = 250;

return 0;
}

Output and program image 

gElectron. Powered by Blogger.