Home / Programs / C Program to Read Array Elements
Programming Example

C Program to Read Array Elements

👁 3,360 Views
💻 Practical Program
📘 Step by Step Learning
In this program we will show you how to read Array Elements in c programming language

Program Code

#include<stdio.h>
 
int main() {
   int i, arr[50], num;
 
   printf("\nEnter no of elements :");
   scanf("%d", &num);
 
   //Reading values into Array
   printf("\nEnter the values :\n");
   for (i = 0; i < num; i++) {
      scanf("%d", &arr[i]);
   }
 
   //Printing of all elements of array
   for (i = 0; i < num; i++) {
      printf(" arr[%d] = %d\n", i, arr[i]);
   }
 
   return (0);
}

Output

Enter no of elements :3

Enter the values :
4
5
6
 arr[0] = 4
 arr[1] = 5
 arr[2] = 6
Press any key to continue . . .

Explanation

Read Array Elements

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.