Initializing the elemets of an array to zeros

#include<stdio.h>


int main (void)
{
    int n[ 10 ]; /* n is array of 10 integers */
    int i; /* counter */
    
    /* initialize elemets of array n to 0 */
    for ( i=0; i < 10; i++){
        n[i]=0;
        }
        
        printf("%s%13s\n", "Element", "Value" );
        
     for (i=0;i< 10; i++){
            printf("%7d%13d\n", i, n[i]);
            }
            
            system ("pause");
            return 0;
            }

No comments:

Post a Comment