Skip to main content

Array pointers arithmetic in c

#include<stdio.h>
int main() {
int arr []={1,4,5,9,7,6};
printf("The value of array at position 3 is %d\n",arr[3]);
printf("The address of first element of array is %d\n",&arr[0]);
printf("The address of first element of array is %d\n",arr);
printf("The address of second element of array is %d\n",&arr[1]);
printf("The address of first element of array is %d\n",arr+1);
printf("The value of address at first element of array is %d\n",*(arr));
printf("The value of address at first element of array is %d\n",*(&arr[0]));
printf("The value of address at second element of array is %d\n",*(&arr[1]));
printf("The value of address at first element of array is %d\n",arr[0]);
printf("The value of address at second element of array is %d\n",*(arr+1));
printf("The value of address at second element of array is %d\n",arr[1]);
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 ;   }