#program to accept and display values of an array
#include <stdio.h>
int main()
{
int a[15],n,i;
printf("Enter how many elements do you want to store into an array");
scanf("%d",&n);
for(i=0;i<n;i++) //accepting array elements from user
{
printf("Enter %d value=",i+1);
scanf("%d",&a[i]);
}
printf("Entered Values are =");
for(i=0;i<n;i++) //Displaying array elements
{
printf("%d ",a[i]);
}
return 0;
}
Output: Testcase-1
Enter how many elements do you want to store into an array 4
Enter 1 value=12
Enter 2 value=43
Enter 3 value=34
Enter 4 value=9
Entered Values are =12 43 34 9
Comments