Write a Program in C That Initializing the Elements of an Array With an Initializer List

// Initializing the elements of an array with an initializer list.
#include <stdio.h>

// function main begins program execution
int main( void )
{
   // use initializer list to initialize array n           
   int n[ 10 ] = { 32, 27, 64, 18, 95, 14, 90, 70, 60, 37 };
   size_t i; // counter
   
   printf( "%s%13s\n", "Element", "Value" );
   
   // output contents of array in tabular format
   for ( i = 0; i < 10; ++i ) {
      printf( "%7u%13d\n", i, n[ i ] );
   } // end for
} // end main

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...