OneBite.Dev - Coding blog in a bite size

create an array of number in C

Code snippet on how to create an array of number in C

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

This code example creates an array of 10 numbers in C. It begins by declaring an array called ‘arr’ with a length of 10. This array will be used to store our numbers. Next, the for-loop iterates from 0 up to 9 and uses the variable ‘i’ to reference the current number. Finally, the for-loop assigns the current number to the array index ‘i’, thus storing the number in the array.

c