Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 3. Handling Data > Initializing Arrays

Initializing Arrays

You can initialize the value of the elements in an array when you declare that array by enclosing the initialization values in curly braces:

#include <stdio.h>

int main()
{
  int scores[5] = {92 , 73 , 57 , 98 ,
    89 };

  printf(
    "The array is %i elements long.",
    sizeof(scores) / sizeof(int));

  return 0;
}


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial