What's new

Help Create a c program that will initialize an array is by using the index of each element

Sakurara

Eternal Poster
Established
Joined
Nov 24, 2016
Posts
580
Reaction
106
Points
393
See exact ouput below
80
60
70
85
75

Pasagut po salamat :)
 
C:
/**
 * C program to read and print elements in an array
 */

#include <stdio.h>
#define MAX_SIZE 1000 // Maximum array size

int main()
{
    int arr[MAX_SIZE]; // Declare an array of MAX_SIZE
    int i, N;

    /* Input array size */
    printf("Enter size of array: ");
    scanf("%d", &N);

    /* Input elements in array */
    printf("Enter %d elements in the array : ", N);
    for(i=0; i<N; i++)
    {
        scanf("%d", &arr[i]);
    }


    /*
     * Print all elements of array
     */
    printf("\nElements in array are: ");
    for(i=0; i<N; i++)
    {
        printf("%d, ", arr[i]);
    }

    return 0;
}
 

Similar threads

Back
Top