Write a program in C to store elements in an array and print it.
Test Data :
Input 10 elements in the array :
element - 0 : 1
element - 1 : 1
element - 2 : 2
Expected Output :
Elements in array are: 1 1 2 3 4 5 6 7 8 9
#include <stdio.h>
void main()
{
int arr[10];
int i;
printf("\n\nRead and Print elements of an array:\n");
print("\n");
printf("Input 10 elements in the array :\n");
for(i=0; i<10; i++)
{
printf("element - %d : ",i);
scanf("%d", &arr[i]);
}
printf("\nElements in array are: ");
for(i=0; i<10; i++)
{
printf("%d ", arr[i]);
}
printf("\n");
}
OUTPUT
Read and Print elements of an array:
Input 10 elements in the array :
element - 0 : 4
element - 1 : 8
element - 2 : 6
element - 3 : 9
element - 4 : 7
element - 5 : 1
element - 6 : 2
element - 7 : 3
element - 8 : 5
element - 9 : 8
Elements in array are: 4 8 6 9 7 1 2 3 5 8
0 Comments