Creates an array with four elements and then carelessly uses index values ranging from -1 to 6. - C Array

C examples for Array:Introduction

Description

Creates an array with four elements and then carelessly uses index values ranging from -1 to 6.

Demo Code

#include <stdio.h> 
  #define SIZE 4 //  w ww . jav  a2s  .c o m
  int main(void) 
  { 
      int value1 = 44; 
      int arr[SIZE]; 
      int value2 = 88; 
      int i; 
   
      printf("value1 = %d, value2 = %d\n", value1, value2); 
      for (i = -1; i <= SIZE; i++) 
          arr[i] = 2 * i + 1; 
   
      for (i = -1; i < 7; i++) 
          printf("%2d  %d\n", i , arr[i]); 
      printf("value1 = %d, value2 = %d\n", value1, value2); 
      printf("address of arr[-1]: %p\n", &arr[-1]); 
      printf("address of arr[4]:  %p\n", &arr[4]); 
      printf("address of value1:  %p\n", &value1); 
      printf("address of value2:  %p\n", &value2); 
   
      return 0; 
  }

Result


Related Tutorials