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

 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]);
 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 

Post a Comment



Contact Form


Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget