How to read and write data in an array?

Long Answer
Views 896

Answer:

In this section you will learn how to read and write data in an array using c programming Language


#include <stdio.h>

int main()
{
    int array[10], n, i;

    // Reading array size
    printf("Enter size of the array (max 10): ");
    scanf("%d", &n);

    // Reading array elements
    printf("Enter array elements:\n");
    for (i = 0; i < n; i++) {
        scanf("%d", &array[i]);
    }

    // Writing (printing) array elements
    printf("Array elements are:\n");
    for (i = 0; i < n; i++) {
        printf("%d ", array[i]);
    }

    return 0;
}



Related Articles:

This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Data Structure, click the links and dive deeper into this subject.

Join Our telegram group to ask Questions

Click below button to join our groups.