What you are doing is printing the value in the array at spot [3][3], which is invalid for a 3by3 array, you need to loop over all the spots and print them.

for(int i = 0; i < 3; i++) {
    for(int j = 0; j < 3; j++) {
        printf("%d ", array[i][j]);
    }
    printf("\n");
} 

This will print it in the following format

10 23 42
1 654 0
40652 22 0

if you want more exact formatting you'll have to change how the printf is formatted.

Answer from twain249 on Stack Overflow
🌐
TutorialsPoint
tutorialspoint.com › learn_c_by_examples › program_to_print_array_in_c.htm
Program to print array in C
START Step 1 → Take an array A and define its values Step 2 → Loop for each value of A Step 3 → Display A[n] where n is the value of current iteration STOP · Let's now see the pseudocode of this algorithm − · procedure print_array(A) ...
Top answer
1 of 6
44

What you are doing is printing the value in the array at spot [3][3], which is invalid for a 3by3 array, you need to loop over all the spots and print them.

for(int i = 0; i < 3; i++) {
    for(int j = 0; j < 3; j++) {
        printf("%d ", array[i][j]);
    }
    printf("\n");
} 

This will print it in the following format

10 23 42
1 654 0
40652 22 0

if you want more exact formatting you'll have to change how the printf is formatted.

2 of 6
13

There is no .length property in C. The .length property can only be applied to arrays in object oriented programming (OOP) languages. The .length property is inherited from the object class; the class all other classes & objects inherit from in an OOP language. Also, one would use .length-1 to return the number of the last index in an array; using just the .length will return the total length of the array.

I would suggest something like this:

int index;
int jdex;
for( index = 0; index < (sizeof( my_array ) / sizeof( my_array[0] )); index++){
   for( jdex = 0; jdex < (sizeof( my_array ) / sizeof( my_array[0] )); jdex++){
        printf( "%d", my_array[index][jdex] );
        printf( "\n" );
   }
}

The line (sizeof( my_array ) / sizeof( my_array[0] )) will give you the size of the array in question. The sizeof property will return the length in bytes, so one must divide the total size of the array in bytes by how many bytes make up each element, each element takes up 4 bytes because each element is of type int, respectively. The array is of total size 16 bytes and each element is of 4 bytes so 16/4 yields 4 the total number of elements in your array because indexing starts at 0 and not 1.

Discussions

How to print a full array?
#include void print_array(int *arr, size_t len) { putchar('{'); int i; for (i = 0; i < len - 1; i++) printf("%d, ", arr[i]); printf("%d}\n", arr[i]); } int main(void) { int arr[] = {1, 2, 3}; size_t len = 3; print_array(arr, len); return 0; } More on reddit.com
🌐 r/C_Programming
16
3
September 7, 2024
How to print all elements of an array in C after I enter all of them? - Stack Overflow
You use another loop, up to how ... printing... StoryTeller - Unslander Monica – StoryTeller - Unslander Monica · 2017-04-12 10:22:34 +00:00 Commented Apr 12, 2017 at 10:22 ... "Enter 10 numbers:" , when you have only allocated space for 9 int a[9]. The result of that program will just be excessive amounts of sadness. ... You have two big problems with the code you show: The first is that you want to enter ten elements into an array containing ... More on stackoverflow.com
🌐 stackoverflow.com
How to print all data from an array in C? - Stack Overflow
A string is an array of characters, so it needs a second dimension. But integers are just single elements. 2022-02-18T22:02:13.493Z+00:00 ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... 1 Is there a way to print an entire array and ... More on stackoverflow.com
🌐 stackoverflow.com
Printing an array [C]
But that's an array of size 6 by 0. N was 0 at the time you created the array. Every access to the array is undefined behaviour. More on reddit.com
🌐 r/learnprogramming
6
2
July 6, 2021
🌐
w3resource
w3resource.com › c-programming-exercises › array › c-array-exercise-1.php
C Program: Read and Print elements of an array - w3resource
September 27, 2025 - The above program first prompts ... the elements of the array using another for loop that runs from i=0 to i<n and uses the printf() function to print each element of the array....
🌐
Scaler
scaler.com › home › topics › program to print array in c
Program to Print Array in C - Scaler Topics
April 4, 2024 - Let us take a look at some of the standard ways to print an array in C. We can use for loop to print the elements of an array in C.
🌐
Tutorial Gateway
tutorialgateway.org › c-program-to-print-elements-in-an-array
C Program to Print Elements in an Array
April 5, 2025 - But this time, we used While Loop to print array elements · #include <stdio.h> int main() { int Array[50], i = 0, j = 0, Number; printf("\nPlease Enter Number of elements in an array : "); scanf("%d", &Number); printf("\nPlease Enter %d elements of an Array \n", Number); while (i < Number) { scanf("%d", &Array[i]); i++; } printf("\n **** Elemenst in this Array are : ****\n"); while (j < Number) { printf(" Element at Array[%d] = %d \n", j, Array[j]); j++; } return 0; }
🌐
Reddit
reddit.com › r/c_programming › how to print a full array?
r/C_Programming on Reddit: How to print a full array?
September 7, 2024 -

In python, I would use a list to store some numbers than print all of them:
x = [1, 2, 3, 4]

print(x) #output = [1, 2, 3, 4]

How should I do it in C with an array?

Another question: is an array similar to the python lists? If not, what type would be it?;

🌐
Quora
quora.com › How-do-I-print-out-an-array-in-C
How to print out an array in C - Quora
Answer (1 of 8): This is a simple program to create an array and then to print it's all elements. Now, just know about arrays. Arrays are the special variables that store multiple values under the same name in the contiguous memory allocation. Elements of the array can be accessed through their...
Find elsewhere
🌐
Javatpoint
javatpoint.com › c-program-to-print-the-elements-of-an-array
C program to print the elements of an array - javatpoint
While loop in C Abort() Function in C Assert in C Floor() Function in C memcmp() in C Find Day from Day in C without Using Function Find Median of 1D Array Using Functions in C Find Reverse of an Array in C Using Functions Find Occurrence of Substring in C using Function Find out Power without Using POW Function in C Exponential() in C Float in C islower() in C memcpy() in C memmove() in C Matrix Calculator in C Bank Account Management System Library Management System in C 8th Sep - Calendar Application in C 8th Sep - va_start() in C programming 8th Sep - Ascii vs Unicode Student Record System
🌐
Academic Help
academichelp.net › coding › c-coding › how-to-print-an-array.html
How to Print an Array in C: Explanation&Examples
October 31, 2023 - This function can take in the array and its size as arguments and then use a loop or recursion within the function to print the array elements. Apart from the basic loop and recursive methods, some advanced techniques include utilizing pointers for array traversal and printing or integrating inline assembly code for optimization. The choice of technique often depends on the specific needs of the program and the programmer’s proficiency.
🌐
YouTube
youtube.com › watch
Print An Array | C Programming Example - YouTube
How to print out the elements of an array in C, including separating array elements by commas, spaces and new lines. Source code: https://github.com/portfol...
Published   December 23, 2022
🌐
GeeksforGeeks
geeksforgeeks.org › c language › c-arrays
Arrays in C - GeeksforGeeks
C · #include <stdio.h> int main() { int arr[] = {2, 4, 8, 12, 16, 18}; int n = sizeof(arr)/sizeof(arr[0]); // Printing array elements for (int i = 0; i < n; i++) { printf("%d ", arr[i]); } return 0; } Output ·
Published   October 17, 2025
🌐
Learn Java
javatutoring.com › c-program-to-read-print-elements-of-array
C Program To Read & Print Elements Of Array | C Programs
February 24, 2026 - If the condition is true then it prints the array element a[i] using printf() function and the function output() calls itself by increasing i value by 1.
🌐
Programiz
programiz.com › c-programming › c-arrays
C Arrays (With Examples)
November 10, 2024 - Here, we have used a for loop to take five inputs and store them in an array. Then, these elements are printed using another for loop.
🌐
Codeforwin
codeforwin.org › home › c program to declare, initialize, input and print array elements
C program to declare, initialize, input and print array elements - Codeforwin
July 20, 2025 - The above method uses array notation to print elements. You can also use pointer notation to access an array in C. The statement arr[i] is equivalent to *(arr + i). ... Enter size of array: 10 Enter 10 elements in the array : 10 20 30 40 50 60 70 80 90 100 Elements in array are : 10, 20, 30, 40, 50, 60, 70, 80, 90, 100,
🌐
freeCodeCamp
freecodecamp.org › news › how-to-print-array-elements-in-given-order-with-and-without-function
How to Print Array Elements in a Given Order with or without a Function
February 16, 2023 - Create an integer array. Take the array elements as input from the user and print all the array elements in the given order and later in reverse order.
🌐
ProCoding
procoding.org › c-program-to-read-and-print-elements-of-array
C Program to read and print elements of array - procoding.org
May 13, 2020 - #include <stdio.h> void main() { int n, i, arr[50]; printf("Enter number of elements: "); scanf("%d", &n); printf("Enter array elements -\n"); for (i = 0; i < n; i++) scanf("%d", &arr[i]); printf("\nArray elements are -\n"); for (i = 0; i < n; i++) printf("%d\n", arr[i]); } C Program to read and print elements of an array using recursion
🌐
Know Program
knowprogram.com › home › how to print an array in c
How to Print an Array in C - Know Program
March 29, 2021 - Enter array elements: 12.5 45.9 84.84 554.65 15.15 The Array elements are: 12.500000 45.900002 84.839996 554.650024 15.150000 · If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or do you find anything incorrect? Let us know in the comments. Thank you! # C TUTORIAL # C PROGRAMS Array Programs ➤ Find Length of Array in C ➤ How to Print an Array in C ➤ Sum of array elements in C ➤ Reverse an Array in C ➤ C program to Copy an Array ➤ Merge Two Arrays in C ➤ Merge Two Sorted Arrays in C ➤ Count Repeated Elem
🌐
LabEx
labex.io › questions › how-to-print-each-element-of-a-c-string-array-136081
How to Print Each Element of a C String Array in C | LabEx
January 22, 2026 - Then, we use a for loop to iterate through the array and print each string using the printf() function. ... Alternatively, you can use pointers to print the elements of a C string array.
🌐
Stack Overflow
stackoverflow.com › questions › 71180114 › how-to-print-all-data-from-an-array-in-c
How to print all data from an array in C? - Stack Overflow
To get the number of elements in an array use sizeof array / sizeof array[0]. for (int i = 0; i < sizeof array / sizeof array[0]; i++) { for (int j = 0; j < sizeof array[i] / sizeof array[i][0]; j++) { printf("%d ", array[i][j]); } printf("\n"); ...