CS50x - Week 2

Photo by Andrew Neel on Unsplash

CS50x - Week 2



2 min read


I have just completed the second week of the course, which focused on arrays. It has been an exciting and challenging week, as I learned the basics of working with arrays in the C programming language.

What are arrays?

Arrays are collections of values that can be stored in a single variable. One of the key concepts that I learned is how to declare and initialize arrays. In C, arrays are declared using square brackets and can hold values of a specific data type.

Interacting with arrays in code

I learned how to access and manipulate the values in an array. Another concept was index notation, which is used to refer to a specific value in an array. For example, array[0] would refer to the first value in the array.

Another important concept that I learned in week two is how to use loops to iterate over an array. I learned about for loops, which can be used to execute code for each value in an array. This is a powerful tool for working with arrays, as it allows one to manipulate the values in an array without having to write repetitive code.

How arrays store data in memory.

Arrays in C programming store data in contiguous blocks of memory. This means that the values in an array are stored next to each other in memory, with no gaps in between. When an array is declared and initialized, the compiler allocates a block of memory that is large enough to hold all of the values in the array.

How to debug your code

Debugging is an important part of programming, and it involves identifying and fixing errors in your code. I learned four methods of debugging which included: print statements, debugging tools, rubber duck debugging and peer review.


I concluded the week by tackling the lab and problem sets which were beneficial for my learning. I feel like I have gained a solid understanding of how to work with arrays in C programming, and I look forward to the next topics in the course, and to applying what I have learned to more complex programming problems.