answersLogoWhite

0


Best Answer

For global/static variables: yes.

For auto variables: no.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: When an array is declared does c automatically initializes its elements to zero?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What restriction must be satisfied by all of the data items represented by an array?

An array is a group of related items that share a common name.All these elements are stored consecutively. An array must be declared before its use in the program. Array size must be specified All Array elements must be assigned to any value for assignment the value. Partial initialization of elements of an array is not allowed. Size must be integer constant enclosed within square brackets The name of the array indicates starting address of an array. Each individual element of array is accessed by a subscript.


How arrays must be handled in c plus plus?

If the array is static it can declared in the structure itself: struct myArrayTag { int num[12]; // array of 12 integers (e.g., 48 bytes). } myArray; If it is dynamic then you must use a pointer and allocate the array outside the structure. You should also maintain a variable in the structure to keep track of how many elements the array currently has: struct myBufferTag { int * array; // Pointer to array of integers. int size; // Size of array (number of elements); } myBuffer;


What are Array variables also called as?

Elements of the array.


What is The number of elements in an array is called?

the length of the array


Are arrays objects?

Yes. Arrays are objects in Java that store multiple variables of the same type. Arrays can hold either primitives or object references, but the array itself will always be an object on the heap, even if the array is declared to hold primitive elements. In other words, there is no such thing as a primitive array, but you can make an array of primitives

Related questions

How do you declare a string array and add elements to it in C plus plus?

You cannot add elements to a fixed array in C or C++. If, however, the array is declared as a pointer to an array, you can add elements by allocating a new array, copying/adding elements as needed, reassigning the new array to the pointer, and deallocating the original array.


What restriction must be satisfied by all of the data items represented by an array?

An array is a group of related items that share a common name.All these elements are stored consecutively. An array must be declared before its use in the program. Array size must be specified All Array elements must be assigned to any value for assignment the value. Partial initialization of elements of an array is not allowed. Size must be integer constant enclosed within square brackets The name of the array indicates starting address of an array. Each individual element of array is accessed by a subscript.


How arrays must be handled in c plus plus?

If the array is static it can declared in the structure itself: struct myArrayTag { int num[12]; // array of 12 integers (e.g., 48 bytes). } myArray; If it is dynamic then you must use a pointer and allocate the array outside the structure. You should also maintain a variable in the structure to keep track of how many elements the array currently has: struct myBufferTag { int * array; // Pointer to array of integers. int size; // Size of array (number of elements); } myBuffer;


What is array literal in as2?

An array literal is a comma-separated list of the elements of an array. An array literal can be used for initializing the elements of an array.


When the size of vetor is fixed in c plus plus?

The size of a vector cannot be fixed because a vector is a wrapper for a dynamic array where resizing occurs automatically (by virtue of the vector class). So, even if you reserved enough memory for n elements in advance, the vector will resize automatically as soon as you push more than n elements. A normal dynamic array does not resize automatically (you have to manually resize the array in order to accommodate more elements than you've allowed), and is therefore more suitable for a fixed size dynamic array. However, if you embed a vector in your own class wrapper (such as fixed_vector), you can reserve n elements in the vector via the constructor, and subsequently control how many elements are pushed onto the vector. Once n elements are pushed, any subsequent elements can be ignored, perhaps raising an exception for added safety.


What does it mean for a subscript to be out-of -bounds?

This is a type of error that usually occurs in computer programs. An array is defined in which the elements of the array are identified by one or more subscripts. Suppose you have an array which is declared to be of dimension 23. Then if the program tries to access element 26 in that array, it cannot because there is no element of the array in that position. That is when you will get this error message.


C plus plus Defines a constant MaxSize equal to 20 Defines array Data whose base type double MaxSize elements Initializes the array Data so that each element is initialized to the square of its index.?

#define MaxSize (20) double Data[MaxSize]; int i; for (i=0; i<MaxSize; i++) Data[i] = i*i;


What is a example of a array?

An ordered array is simply an array where all elements are in sorted order: int a[] = {3, 6, 9, 10, 15, 21}; // ordered array An array can either be initialised with ordered elements or the elements may be sorted after initialisation. When inserting new elements into an ordered array, the order must be maintained.


What are Array variables also called as?

Elements of the array.


What is The number of elements in an array is called?

the length of the array


Can you change the base address of an array during run time?

If the compiler allocated the array at compile time, or if the array was automatically allocated as a local variable, then no, you cannot change its base address at run time. If you allocated the array at run time from the heap, you can change its base address by allocating a new array, copying the old elements from old to new and deleting the old array.


Are arrays objects?

Yes. Arrays are objects in Java that store multiple variables of the same type. Arrays can hold either primitives or object references, but the array itself will always be an object on the heap, even if the array is declared to hold primitive elements. In other words, there is no such thing as a primitive array, but you can make an array of primitives