Home

A program to initialize a single dimensional array

C Programming Language 049

The following code shows how to write a program to initialize a single dimensional array.

Program

#include <stdio.h>

void main() {
    int a[3] = {1,2,3};
    printf("%d\n", a[0]);
    printf("%d\n", a[1]);
    printf("%d\n", a[2]);

    printf("\n");
}

Result

1
2
3


Last Updated on

Next Post: Rules vs Guidelines →

Comments