SlideShare una empresa de Scribd logo
1 de 10
Array in C Language
Index

Introducing Arrays.
Declaration of a Array. Variables,
 Creating Arrays.
The Length of Arrays.
Initializing Arrays.
Multidimensional Arrays.
Introducing Arrays
 Array is a data structure that represents a
  collection of the same types of data.
                int num[10];
Num reference                  num [0]
                               num[1]
                               num[2]
                               num [3]
                                         An Array of 10 Elements
                               num[4]    of type int.
                               num[5]
                               num[6]
                               num[7]
                               num[8]
                               num[9]
Declaring Array Variables


 Data type array name[index];
   Example:
            int list[10];
          char num[15];
          float hat[20];
Creating Arrays
 Data type array-name[size];
  Example:
          int num[10];


 num[0]references the first element in the
 array.
 num[9]references the last element in the
 array.
The Length of Arrays
 Once an array is created, its size is fixed. It
  cannot be changed.
  For Example,
              int arr[10];


   You can not insert any number to arr[11]
  location because it is not initialized.
Initializing Arrays

 Declaring, creating, initializing in one
  step:
    int my Array[5] = {1, 2, 3, 4, 5};
    int studentAge[4];
        studentAge[0] = 14;
        studentAge[1] = 13;
        studentAge[2] = 15;
        studentAge[3] = 16;
Multidimensional Arrays
  int matrix[10] [10];
for (i=0; i<10; i++)
  for (j=0; j<10; j++)
{
     matrix[i] [j] = i * j;
     }

float mat[5] [5];
Multidimensional Array
          Illustration
    0   1    2   3   4       0   1    2   3   4
                                                           0    1        2
0                        0
                                                  0        1    2        3
1                        1
                                                  1        4    5        6
2                        2       7
                                                  2        7    8        9
3                        3
                                                  3        10   11       12
4                        4

int matrix[5] [5];                                    int[][] array ={
                         matrix[2] [1] = 7
                                                      {1, 2, 3},
                                                      {4, 5, 6},
                                                      {7, 8, 9},
                                                      {10, 11, 12}};
Initializing of
           Multidimensional Arrays
To declare, create and initialize a
  multidimensional array.
For example,
     int[][] array = {
       {1, 2, 3},
       {4, 5, 6},
       {7, 8, 9},
       {10, 11, 12}
};

This is equivalent to the following statements:
      array[0][0] = 1;    array[0][1] = 2; array[0][2] = 3;
      array[1][0] = 4;    array[1][1] = 5; array[1][2] = 6;
      array[2][0] = 7;    array[2][1] = 8; array[2][2] = 9;
      array[3][0] = 10;   array[3][1] = 11; array[3][2] = 12;

Más contenido relacionado

La actualidad más candente (20)

One dimensional 2
One dimensional 2One dimensional 2
One dimensional 2
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
Array in c programming
Array in c programmingArray in c programming
Array in c programming
 
Arrays in c language
Arrays in c languageArrays in c language
Arrays in c language
 
Java Tokens
Java  TokensJava  Tokens
Java Tokens
 
Arrays in java
Arrays in javaArrays in java
Arrays in java
 
Presentation on array
Presentation on array Presentation on array
Presentation on array
 
Java constructors
Java constructorsJava constructors
Java constructors
 
Arrays
ArraysArrays
Arrays
 
1 D Arrays in C++
1 D Arrays in C++1 D Arrays in C++
1 D Arrays in C++
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
Java Arrays
Java ArraysJava Arrays
Java Arrays
 
C pointer
C pointerC pointer
C pointer
 
Multidimensional array in C
Multidimensional array in CMultidimensional array in C
Multidimensional array in C
 
Strings in C
Strings in CStrings in C
Strings in C
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array ppt
 
Structure in C
Structure in CStructure in C
Structure in C
 
String functions in C
String functions in CString functions in C
String functions in C
 

Destacado (7)

Structure in C
Structure in CStructure in C
Structure in C
 
Structure c
Structure cStructure c
Structure c
 
Structure of a C program
Structure of a C programStructure of a C program
Structure of a C program
 
Structure in c
Structure in cStructure in c
Structure in c
 
Arrays in C language
Arrays in C languageArrays in C language
Arrays in C language
 
String c
String cString c
String c
 
String in c
String in cString in c
String in c
 

Similar a Array in c language (20)

Arrays in CPP
Arrays in CPPArrays in CPP
Arrays in CPP
 
07slide
07slide07slide
07slide
 
JavaYDL7
JavaYDL7JavaYDL7
JavaYDL7
 
Multi dimensional arrays
Multi dimensional arraysMulti dimensional arrays
Multi dimensional arrays
 
pptt.pptx
pptt.pptxpptt.pptx
pptt.pptx
 
Lecture17 arrays.ppt
Lecture17 arrays.pptLecture17 arrays.ppt
Lecture17 arrays.ppt
 
Array
ArrayArray
Array
 
Arrays
ArraysArrays
Arrays
 
array
array array
array
 
รายงานคอม
รายงานคอมรายงานคอม
รายงานคอม
 
Array
ArrayArray
Array
 
7. arrays
7. arrays7. arrays
7. arrays
 
Array
ArrayArray
Array
 
Array in c language
Array in c languageArray in c language
Array in c language
 
Array in c language
Array in c languageArray in c language
Array in c language
 
รายงานคอม
รายงานคอมรายงานคอม
รายงานคอม
 
L10 array
L10 arrayL10 array
L10 array
 
Unit4 Slides
Unit4 SlidesUnit4 Slides
Unit4 Slides
 
Lecture 6 - Arrays
Lecture 6 - ArraysLecture 6 - Arrays
Lecture 6 - Arrays
 
Arrays
ArraysArrays
Arrays
 

Más de home

3D Printer
3D Printer3D Printer
3D Printerhome
 
Software project management by Walker Royce
Software project management by Walker RoyceSoftware project management by Walker Royce
Software project management by Walker Roycehome
 
Asp interview Question and Answer
Asp interview Question and Answer Asp interview Question and Answer
Asp interview Question and Answer home
 
Matrimonial web site Documentation
Matrimonial web site DocumentationMatrimonial web site Documentation
Matrimonial web site Documentationhome
 
Linux
LinuxLinux
Linuxhome
 
Internet Technology
Internet TechnologyInternet Technology
Internet Technologyhome
 
Internet Technology
Internet TechnologyInternet Technology
Internet Technologyhome
 
Internet Technology
Internet TechnologyInternet Technology
Internet Technologyhome
 
Software techniques
Software techniquesSoftware techniques
Software techniqueshome
 

Más de home (9)

3D Printer
3D Printer3D Printer
3D Printer
 
Software project management by Walker Royce
Software project management by Walker RoyceSoftware project management by Walker Royce
Software project management by Walker Royce
 
Asp interview Question and Answer
Asp interview Question and Answer Asp interview Question and Answer
Asp interview Question and Answer
 
Matrimonial web site Documentation
Matrimonial web site DocumentationMatrimonial web site Documentation
Matrimonial web site Documentation
 
Linux
LinuxLinux
Linux
 
Internet Technology
Internet TechnologyInternet Technology
Internet Technology
 
Internet Technology
Internet TechnologyInternet Technology
Internet Technology
 
Internet Technology
Internet TechnologyInternet Technology
Internet Technology
 
Software techniques
Software techniquesSoftware techniques
Software techniques
 

Último

Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 

Último (20)

Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 

Array in c language

  • 1. Array in C Language
  • 2. Index Introducing Arrays. Declaration of a Array. Variables, Creating Arrays. The Length of Arrays. Initializing Arrays. Multidimensional Arrays.
  • 3. Introducing Arrays  Array is a data structure that represents a collection of the same types of data. int num[10]; Num reference num [0] num[1] num[2] num [3] An Array of 10 Elements num[4] of type int. num[5] num[6] num[7] num[8] num[9]
  • 4. Declaring Array Variables  Data type array name[index]; Example: int list[10]; char num[15]; float hat[20];
  • 5. Creating Arrays  Data type array-name[size]; Example: int num[10]; num[0]references the first element in the array. num[9]references the last element in the array.
  • 6. The Length of Arrays  Once an array is created, its size is fixed. It cannot be changed. For Example, int arr[10]; You can not insert any number to arr[11] location because it is not initialized.
  • 7. Initializing Arrays  Declaring, creating, initializing in one step: int my Array[5] = {1, 2, 3, 4, 5}; int studentAge[4]; studentAge[0] = 14; studentAge[1] = 13; studentAge[2] = 15; studentAge[3] = 16;
  • 8. Multidimensional Arrays int matrix[10] [10]; for (i=0; i<10; i++) for (j=0; j<10; j++) { matrix[i] [j] = i * j; } float mat[5] [5];
  • 9. Multidimensional Array Illustration 0 1 2 3 4 0 1 2 3 4 0 1 2 0 0 0 1 2 3 1 1 1 4 5 6 2 2 7 2 7 8 9 3 3 3 10 11 12 4 4 int matrix[5] [5]; int[][] array ={ matrix[2] [1] = 7 {1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}};
  • 10. Initializing of Multidimensional Arrays To declare, create and initialize a multidimensional array. For example, int[][] array = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12} }; This is equivalent to the following statements: array[0][0] = 1; array[0][1] = 2; array[0][2] = 3; array[1][0] = 4; array[1][1] = 5; array[1][2] = 6; array[2][0] = 7; array[2][1] = 8; array[2][2] = 9; array[3][0] = 10; array[3][1] = 11; array[3][2] = 12;