C Program using an array with a loop


In this program, You will learn how to implement an array with a loop in c.


for (int i = 0; i < 10; i++) {
    cin >> arr[i]; 
}

Example: How to implement an array with a loop in c.

#include<stdio.h>

int main() {

   int arr[10], i;

   printf("Enter 5 numbers:");
   for (i = 0; i < 5; i++) {
       scanf("%d", &arr[i]);
   }

   printf("List of Array:");
   for (i = 0; i < 5; i++) {
       printf("%d ", arr[i]);
   }

   return 0;
}

Output:

Enter 5 numbers:10 20 30 40 50                                                                                                         
List of Array:10 20 30 40 50

Xiith is created for educational, experimental, and schooling purpose. Examples on Xiith are made easier to make a better or basic understanding. Tutorials, testimonials, and examples are continuously checked to avoid delusion, but we cannot take complete responsibility of all programs on Xiith. When you are operating this site, you have to agree to read and accept our terms of use, cookie and privacy policy.Copyright © 2020 by Xiith. All Rights Reserved. About us.