C Language - Arrays and Pointers

 



#include <stdio.h>

#include <conio.h>

int main()

{

int array [] = {10, 20, 30, 40};

int *ptr = &array;

int a=22;

int *ptr2 = a;

a++;

printf ("The value of array is %d\n", array[0]);

printf ("The value of array is %d\n", array[1]);

printf ("The value of array is %d\n", array[2]);

printf ("The value of array is %d\n", array[3]);

printf ("The value of array is %d\n", ptr[0]);

printf ("The value of array is %d\n", ptr[3]);

printf ("\n");

printf ("The value of a is %d\n", a);

printf ("The value of array is %d\n", &ptr2);

printf ("The value of array is %d\n", a++);



printf ("\n");


printf ("The address of array is %d\n", array );

printf ("\n");

printf ("The address of array is %d\n", &array[0]+1);

printf ("The address of array is %d\n", array +1);

printf ("\n");

printf ("The address of array is %d\n", &array[1]);

printf ("\n");

printf ("The address of array is %d\n", &array[1]+1);

printf ("The address of array is %d\n", array +2);

printf ("\n");

printf ("The address of array is %d\n", &array[2]);

printf ("\n");

printf ("The address of array is %d\n", &array[2]+1);

printf ("The address of array is %d\n", array +3); 


return 0;

}


// ScreenShots:





Comments

Popular Posts