0% found this document useful (0 votes)
4 views2 pages

Read and Display Array Elements in C

The document contains a C program that prompts the user to enter a number of elements and stores them in an array. It then displays the entered array elements. The program is designed to handle up to 20 elements.

Uploaded by

MUKTA PUJAR
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Read and Display Array Elements in C

The document contains a C program that prompts the user to enter a number of elements and stores them in an array. It then displays the entered array elements. The program is designed to handle up to 20 elements.

Uploaded by

MUKTA PUJAR
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1.

Write a program to read and display n number using an array

#include <stdio.h>

int main()

int i=0, n, arr[20];

printf("\n Enter the number of elements:");

scanf("%d",&n);

for(i=0; i<n; i++)

printf("\n Arr[%d] = ", i);

scanf("%d", &arr[i]);

printf("\n the array elements are");

for(i=0; i<n; i++)

printf("Arr[%d] = %d\t", i, arr[i]);

return 0;

Output:
Enter the number of elements:5

Arr[0] = 1

Arr[1] = 2

Arr[2] = 3

Arr[3] = 4

Arr[4] = 5

the array elements areArr[0] = 1 Arr[1] = 2 Arr[2] = 3 Arr[3] = 4 Arr[4] = 5

You might also like