Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - C language assumes that there are five elements in the array int a[5]. How many bytes does it take to reach 20?
C language assumes that there are five elements in the array int a[5]. How many bytes does it take to reach 20?
Generally, the type of int accounts for 4 bytes, and the type of int in array A has 5 elements, that is, 4 * 5 = 20 bytes. Generally speaking, in C language, the number of bytes occupied by an array is obtained by the sizeof operator. The execution steps are as follows:

# Contains? & ltstdio.h & gt。

int? main().

{。

int? A word [5].

Printf ("Number of bytes occupied by array A: %d\n",? sizeof(a)? )。

Return? 0。

}。

Extended data:

The characteristics of c language:

1, C language is a procedural language with structured programming, variable scope and recursive functions.

2. The parameters passed by C language are all values, or a pointer can be passed.

3. Different variable types can be combined with structures.

4. Only 32 reserved keywords make the naming of variables and functions more flexible. Some variable types can be converted, such as integer and character variables. Through pointers, C language can easily control the memory at a low level. Preprocessor makes the compilation of C language more flexible.