C – Arrays

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/c-arrays/
PINTEREST
PINTEREST
INSTAGRAM

C Programming Tutorial Index

  1. Introduction To Programming
  2. C Setup Development Environment
  3. C Hello World and Compile First Application
  4. C Syntax and Basics
  5. C Variables
  6. C Numeric Variable Types (Integer, Long, Float)
  7. C String Variables
  8. C Constants and Define Processor
  9. C Operators
  10. C If Else and Switch Case Conditionals
  11. C While Loops
  12. C For Loops
  13. C Arrays
  14. C Functions
  15. C Structure
  16. C Union
  17. C File Operations (Open, Read, Write)
  18. C Pointers
  19. C Type Casting
  20. C Header Files and Include

Arrays are different from primitive types like integer,chars. Arrays provides fixed length sequential data. All of the data is same type. We can think array like a same type list. Arrays uses indexes to specify specific item in array.

Declaring Arrays

There is two must do to define array. One is the type of the array and second is length of the array. Basic syntax of defining array is like below;

For example if we want to define an integer type array with 10 items we can use following code.

As another example to define and float array to store average temprature for 31 days we can use following array

After defining arrays according to their types and sizes some storage is allocated in memory. So while developing C programs array types and sizes must be set cautiously because it can creates low memory problems.

Initializing Arrays

Initializing means setting values to the newly created array. Arrays in C can be initialized in different ways.

Loop Through Arrays

As we know arrays are sequential data types. Looping through arrays are very popular and useful way to consume array data. We will look some examples about how to enumerate array data with loops.

LEARN MORE  Display Detailed System Information With Systeminfo For Windows Operating Systems

Multidimensional Arrays

Arrays are accessed with index numbers. Arrays those have single line of data are named single dimension arrays. Arrays can be used int matrix or similar structure operations without using multiple arrays. More than one line of arrays are called multi dimension arrays.

As we see we add new brackets according to dimensions. If there is more than 2 dimensions we will add more [size] brackets.

C Programming Tutorial Index

  1. Introduction To Programming
  2. C Setup Development Environment
  3. C Hello World and Compile First Application
  4. C Syntax and Basics
  5. C Variables
  6. C Numeric Variable Types (Integer, Long, Float)
  7. C String Variables
  8. C Constants and Define Processor
  9. C Operators
  10. C If Else and Switch Case Conditionals
  11. C While Loops
  12. C For Loops
  13. C Arrays
  14. C Functions
  15. C Structure
  16. C Union
  17. C File Operations (Open, Read, Write)
  18. C Pointers
  19. C Type Casting
  20. C Header Files and Include
RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/c-arrays/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)