// Program to take 5 values from the user and store them in an array
// Print the elements stored in the array
#include <stdio.h>
int main() {
int values[5];
printf("Enter 5 integers: ");
// taking input and storing it in an array
for(int i = 0; i < 5; ++i) {
scanf("%d", &values[i]);
}
printf("Displaying integers: ");
// printing elements of an array
for(int i = 0; i < 5; ++i) {
printf("%d
", values[i]);
}
return 0;
}
/**
* 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("
Elements in array are: ");
for(i=0; i<N; i++)
{
printf("%d, ", arr[i]);
}
return 0;
}