Computer Science  SLO Based Key Point Notes

👉👉👉 Computer Science 12th Class Notes (Main Page)

************************************

Unit 5: Arrays and String


5.1.3. Initialization of Array

  • To initialize an array, the initializing values are enclosed within the curly braces in the declaration and placed following an equal sign after the array name. Here is an example:
            int myArray[5] = {1, 2, 3, 4, 5, 6};
  • If the number of values supplied are less than the actual number of item in the list then extra spaces in the array will be filled in with zeroes.
  • If the number of values supplied is greater than the actual size of the array then the compiler will give an error message.
  • If the size of the array is not supplied, the compiler will count the number of items in the initialization list and fix that as the array size. For example:
                    int myArray[] = {5, 6, 8, 6, 9, 6};


************************************
👉👉👉 Computer Science 12th Class Notes (Main Page)

************************************


(National Book Foundation - As Federal Textbook Board, Islamabad 
Based on National Curriculum Pakistan 2023-2024 and Onward prescribed by Federal Board of Intermediate and Secondary Education, Islamabad, and All Pakistan Boards) 

{Contact WhatsApp 03339719149 for Class-XII Computer Science Complete SLO-Based Key Points notes in pdf format as well as in PowerPoint Presentation for preparing/delivering the Lectures}
Note:  Write me in the comments box below for any query and also Share this information with your class-fellows and friends.