OUTLINE 1)How to declare and define one dimensional array. 2)How To access Array Element. 3)How to initialize one dimensional array. ( NOTE: Size of integer is 4 bytes). 1) (The length of array can be specified by any integer constant expression. int arr[5]; int arr[5+5]; int arr[21/3]; int arr[4*3]; Specifying the length of an array using MACRO is considered to be an excellent practice. # define N 10 int arr[N]; 2)I NITIALIZING 1D ARRAY METHOD-1: [NOT TOO MUCH USED] arr[5]={2,3,4,5,5}; METHOD-2: arr[]={1,23,34,45,6}; METHOD:3 [NOT USEFUL] int arr[3]; int arr[0]=1; int arr[1]=2 int arr[2]=12; METHOD:4 int arr[5]; for(int i=1;i<5;i++) { scanf("%d",&arr[i]); } SUMMARY 1)IF THE NO, OF ELEMENT ARE LESS THAN THE LENGTH OF THE ARRAY THAN THE REST OF THE LOCATION ARE AUTOMATICALLY FILLED BY VALUE 0; 2)EASY WAY TO INITIALISE AN ARRAY WITH ALL ZEROS IS GIVEN BY: int arr[10]={0}; 3)AT THE TIME OF INITIALIZATION ,NEVER LEAVE THESE FLOWER BRACKET{} EMPTY AND ALSO NEVE...
Comments
Post a Comment