অনুরূপ অনেক Data একসাথে স্টোর করতে array এর ব্যবহার

Submitted by tushar pramanick on Mon, 01/02/2012 - 15:52

Storing Similar Data Items

In last Chapter you learned about pointers and the concept of indirection. In this lesson you'll learn about arrays, which are collections of similar data items and are closely related to pointers. The main topics covered in this lesson are

    Single-dimension arrays
    Indexing arrays
    Pointers and arrays
    Character arrays
    Multidimensional arrays
    Unsized arrays



Summary

In this lesson you've learned the following:

  •     An array is a collection of variables that are of the same data type.
  •     In C, the index to an array starts at 0.
  •     You can initialize each individual element of an array after the declaration of the array, or you can place all initial values into a data block surrounded by { and } during the declaration of an array.
  •     The memory storage taken by an array is determined by the product of the size of the data type and the dimensions of the array.
  •     A pointer is said to refer to an array when the address of the first element in the array is assigned to the pointer. The address of the first element in an array is also called the start address of the array.
  •     To assign the start address of an array to a pointer, you can either put the combination of the address-of operator (&) and the first element name of the array, or simply use the array name, on the right side of an assignment operator (=).
  •     A character array is considered a character string in C if the last element in the array contains a null character (\0).
  •     The null character (\0) marks the end of a string. C functions, such as printf(), will stop processing the string when the null character is encountered.
  •     C supports multidimensional arrays, too. A pair of brackets (the array subscript operator—[ and ]) indicates a dimension.
  •     The compiler can automatically calculate the memory space needed by an unsized array.

 

 

Related Items

The while Loop

The while Loop

The while statement is also used for looping. Unlike the situation with the for statement, there is only one expression field in the while statement.

The general form of the while statement is

while (expression) {

Question and Answer

Question and Answer

    Q How does a for loop work?

Exercises : Answer the following Question

To help you solidify your understanding of this hour's lesson, you are encouraged to try to answer the quiz questions and finish the exercises provided in the Workshop before you move to the next lesson.

 

Working with the Cast Operator

Playing with the Cast Operator

In C, you can convert one data type to a different one by prefixing the cast operator to the operand.

The general form of the cast operator is

(data-type)x

Question and Answer

Question and Answer

    Q What is the difference between the pre-increment operator and the post-increment operator?