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
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.

๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ home โ€บ learn_c_by_examples โ€บ print array in c
Program to print array in C
May 2, 2016 - 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) ...
Discussions

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
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
C: print an array - Stack Overflow
Explore Stack Internal ... I've started learning C yesterday, and the only other language I know is Python. I'm having some trouble with arrays, because they are quite different from the Python lists. I tried to print an array, not an element of it, but the array itself. More on stackoverflow.com
๐ŸŒ stackoverflow.com
c - Is there a way to have printf() properly print out an array (of floats, say)? - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... I believe I have carefully read the entire printf() documentation but could not find any way to have it print out, say, the elements of a 10-element array of float(s). More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
W3Schools
w3schools.com โ€บ c โ€บ c_arrays.php
C Arrays
To create an array, define the data type (like int) and specify the name of the array followed by square brackets [].
๐ŸŒ
Reddit
reddit.com โ€บ r/learnprogramming โ€บ printing an array [c]
r/learnprogramming on Reddit: Printing an array [C]
July 6, 2021 -

I'm trying to print out an array with a set number of rows and variable columns. It can print one and two columns fine but any higher than three, it just shows three total cells.

#include<stdio.h>
 
int main(void)
{
int N = 0;
int i = 0;
int j = 0;
double container [6][N];

printf("Please enter the number of containers to be entered: ");
scanf("%d", &N);

for (i=0; i<6; i++){
    for(j=0; j<N; j++){
    container [i][j] = 0;
    printf("%lf  ", container[i][j]);
    }
    printf("\n");
}
return 0;
}

With 2 as input:

Please enter the number of containers to be entered: 2 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000

When higher than 2:

Please enter the number of containers to be entered: 3 0.000000 0.000000 0.000000

๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c language โ€บ c-arrays
Arrays in C - GeeksforGeeks
Array declaration is the process of specifying the type, name, and size of the array. In C, we have to declare the array like any other variable before using it.
Published ย  October 17, 2025
๐ŸŒ
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...
๐ŸŒ
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 - In this way, we can take each value from the user and store it in our array in a sequential way. Keep in mind that the array always starts from the 0 index (the first element is at index 0, the second is at index 1, and so on). Now it is time to print all the array elements (the value that each index of the array has) in the given order.
Find elsewhere
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ program to print array in c
Program to Print Array in C - Scaler Topics
April 4, 2024 - We create an array arr initially and then we iterate over all the elements of the array using the for loop and then print the ith element in the ith iteration. We can also use a while loop to print the elements of an array in C.
๐ŸŒ
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?;

๐ŸŒ
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 - Write a C program to input elements into an array dynamically using malloc() and print the array without using indexing.
๐ŸŒ
Academic Help
academichelp.net โ€บ coding โ€บ c-coding โ€บ how-to-print-an-array.html
How to Print an Array in C: Explanation&Examples
November 4, 2023 - This C program initializes an array with 5 integers and then prints each element sequentially. While the for loop is the most common method to traverse and print an array, you can achieve the same with while loops and do-while loops.
๐ŸŒ
Dhgate
smart.dhgate.com โ€บ mastering-array-printing-in-c-practical-techniques-and-common-pitfalls-explained
Mastering Array Printing in C: Practical Techniques and ...
November 7, 2025 - Find expert-backed shopping guides and top product picks from DHgate. Make smarter decisions with curated insights tailored for international buyers.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ home โ€บ learn_c_by_examples โ€บ print reverse array in c
Program to print reverse array in C
May 2, 2016 - START Step 1 โ†’ Take an array A and define its values Step 2 โ†’ Loop for each value of A in reverse order 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) FOR from array_length(A) to 0 DISPLAY A[n] END FOR end procedure
๐ŸŒ
Medium
medium.com โ€บ @ryan_forrester_ โ€บ print-array-in-c-a-comprehensive-guide-4a2171b122e3
Print Array in C++: A Comprehensive Guide | by ryan | Medium
October 17, 2024 - By overloading the << operator for our SensorReading struct, we can easily print the entire dataset and perform analysis on it. Printing arrays in C++ offers various approaches, each with its own strengths.
๐ŸŒ
Code Maze
code-maze.com โ€บ home โ€บ different ways to print the elements of an array in c#
Different Ways to Print The Elements of an Array in C# - Code Maze
July 13, 2022 - We use the Console.Write method to print all the elements. However, we have to provide those elements. This is where the Join method comes into play. Its responsibility is to concatenate every element of the array (the second parameter) separating each with the string separator (first parameter). Is this material useful to you? Consider subscribing and get ASP.NET Core Web API Best Practices eBook for FREE!
๐ŸŒ
Tutorial Gateway
tutorialgateway.org โ€บ c-program-to-print-elements-in-an-array
C Program to Print Elements in an Array
April 5, 2025 - In this example, it will be from 0 to 7 ... First Iteration: for (i = 0; 0 < 5; 0++) Condition is True, so the Programming compiler will print the first element(10) in the One Dimensional Array.
๐ŸŒ
w3resource
w3resource.com โ€บ c-programming-exercises โ€บ basic-declarations-and-expressions โ€บ c-programming-basic-exercises-50.php
C Program: Print the position and value of an array elements - w3resource
September 18, 2025 - Write a C program to read an array ... size 5 to hold floating-point numbers int i; // Prompt for user input printf("Input the 5 members of the array:\n"); // Read and store user input into the array for(i = 0; i < AL; i++) { ...