0

What is arrays in C language?

28th Apr 2023, 7:47 AM
Akash Deep
Akash Deep - avatar
4 Answers
+ 4
Hi there! Arrays in C are like a bunch of boxes that you can use to store a bunch of things. Let's say you want to keep track of your favorite colors. You could use one box to store one color, but that would get pretty messy if you have a lot of colors. Instead, you could use an array! An array is like a row of boxes, all lined up next to each other. You can give each box a number, called an index, so you can easily find the color you want. For example, you could create an array of your favorite colors like this: char favorite_colors[5] = {'red', 'blue', 'green', 'yellow', 'purple'}; Now you have an array of 5 boxes, each one storing a different color. You can access each box by using its index. For example, if you want to know your second favorite color, you can use the index 1 (remember, indices start at 0 in C): printf("My second favorite color is %s", favorite_colors[1]); And that's it! Arrays are a really useful way to store a bunch of things in C, and they're pretty easy to understand once you get the hang of them.
28th Apr 2023, 8:43 AM
Harshika Malhotra
Harshika Malhotra - avatar
+ 8
Akash Deep , > since you have missed learning the *basics* of *c language* with sololearn, i would recommend to do so. arrays are explained there. > also practice with arrays as much as you can afford. here is a list of short tutorials related to areays: https://www.sololearn.com/learn/C/2931/?ref=app https://www.sololearn.com/learn/C/2932/?ref=app https://www.sololearn.com/learn/C/2950/?ref=app https://www.sololearn.com/learn/C/2934/?ref=app
28th Apr 2023, 10:28 AM
Lothar
Lothar - avatar
+ 8
You can learn c language from sololearn
28th Apr 2023, 12:29 PM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 3
An array in C is a variable that contains various elements of the same data type. Example: int c[3] = {1, 2, 3}; This is an array that contains 3 integers. You can get an element with subindex. int c[3] ={ 1, 2 , 3 } c[0] c[1] c[2] Subindex START COUNTING BY 0. All this concepts are explained in sololearn c course, so finish it and you will learn this and more!
28th Apr 2023, 7:56 AM
Ugulberto SĂĄnchez
Ugulberto SĂĄnchez - avatar