How to declare and initialize an array in C++?

clock icon

asked 5 months ago Asked

message

1 Answers

eye

8 Views

 I'm new to C++ and want to understand how to declare and initialize arrays. Can someone provide a simple example of how to declare an array, assign values to it, and access its elements?

1 Answers

To declare an array in C++, you need to define

  • The data type of elements in the array
  • The name of the array
  • The size of the array

    Syntax:

              Data_type Array_Name [size];

Depicted below is an example of a declaration of the array.

Example:

                 int club[10];

Write your answer here

Top Questions