{"id":81438,"date":"2021-07-30T09:00:27","date_gmt":"2021-07-30T03:30:27","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=81438"},"modified":"2021-07-30T09:00:27","modified_gmt":"2021-07-30T03:30:27","slug":"arrays-in-c","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/arrays-in-c\/","title":{"rendered":"Arrays in C &#8211; Properties, Syntax and Examples"},"content":{"rendered":"<p>Arrays are one of the most conceptual and used features of the C programming language. It is the simplest data structure algorithm where random elements can be accessed with their index number. It is one of the simplest programming languages. And, you can easily use data structure algorithms in C.<\/p>\n<p>In C, arrays are structured data types. Let us learn more about it.<\/p>\n<h3>What are Arrays in C?<\/h3>\n<p>Arrays are simply a collection of similar data types stored at contiguous memory locations. It can store primitive types of data like int, char, float, double etc. With the help of the arrays, a programmer can access the elements very easily.<\/p>\n<p>Suppose, you want to store marks of 20 students then you might try to declare 20 variables like student1_marks, student2_marks etc. But what if i tell you that you can do all those with a single variable named array. By the help of a few lines of code, you can access those elements.<\/p>\n<table style=\"height: 44px\" width=\"250\">\n<tbody>\n<tr>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400\">\u00a0 \u00a0 \u00a00<\/span>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<span style=\"font-weight: 400\">1<\/span> <span style=\"font-weight: 400\">\u00a0 \u00a0 \u00a0 \u00a0 2<\/span> <span style=\"font-weight: 400\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 3<\/span> <span style=\"font-weight: 400\">\u00a0 \u00a0 \u00a0 \u00a04<\/span><\/p>\n<p><b>Array of size 5<\/b><\/p>\n<h3>Properties of array in C<\/h3>\n<ul>\n<li>An array is a variable that can store a fixed-size collection of elements of the same data type.<\/li>\n<li>You can access the elements inside of an array randomly. You can also calculate the address of each element in an array.<\/li>\n<li>Elements of the array stored at contiguous memory locations.<\/li>\n<\/ul>\n<h3>Advantages of an array in C<\/h3>\n<ul>\n<li>You can access the elements of the array randomly.<\/li>\n<li>You can also sort the elements in an array with just a few lines of code.<\/li>\n<li>It is easy to access the data of the array.<\/li>\n<\/ul>\n<h3>Disadvantages of an array in C<\/h3>\n<ul>\n<li>The array has to be fixed size. You can not exceed the limit of it. And it does not have the feature to grow dynamically like LinkedList.<\/li>\n<\/ul>\n<h3>How to declare an array?<\/h3>\n<p><strong>Syntax for declaring an array:-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">dataType array_name[arraySize];<\/pre>\n<p><strong>Example:- Declare an array<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">int student_marks[20];\nchar student_name[10];\nfloat numbers[5];\n<\/pre>\n<p><strong>Note:-<\/strong> After the declaration, size of the array cannot be changed.<\/p>\n<h3>Access elements of an array in C<\/h3>\n<p>In C, you can access the elements of the array using their indices.<\/p>\n<p>Suppose, you declare an array like below:-<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">int numbers[5];<\/pre>\n<p>If you want to access the first element of the above array then do <strong>numbers[0]<\/strong> and if you want to access the second element then do <strong>numbers[1]<\/strong> and so on.<\/p>\n<ul>\n<li>The first index of the array is 0 not 1. That\u2019s why <strong>numbers[0]<\/strong> is the first element.<\/li>\n<li>To access the last element of the array, do <strong>numbers[4].<\/strong><\/li>\n<\/ul>\n<table>\n<tbody>\n<tr>\n<td><b>numbers[0]<\/b><\/td>\n<td><b>numbers[1]<\/b><\/td>\n<td><b>numbers[2]<\/b><\/td>\n<td><b>numbers[3]<\/b><\/td>\n<td><b>numbers[4]<\/b><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><b> 2<\/b> <b>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 3<\/b> <b>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a04<\/b>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<b>5<\/b> <b>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 6<\/b><\/p>\n<h3>Initialize an array:-<\/h3>\n<p>At the time of declaration, it is possible to initialize an array.<\/p>\n<p><strong>Syntax to initialize an array:-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">int numbers[5] = {2, 3, 4, 5, 6};<\/pre>\n<p>You can also initialize an array like below:-<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">int numbers[] = {2, 3, 4, 5, 6};<\/pre>\n<p>In case, if you don\u2019t specify the size of the array during initialization then the compiler will know it automatically.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">numbers[0] = 2\nnumbers[1] = 3\nnumbers[2] = 4\nnumbers[3] = 5\nnumbers[4] = 6\n<\/pre>\n<p><strong>Basic Example of an array:-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include&lt;stdio.h&gt;\n\nint main()\n{\nint numbers[5] = {2, 3, 4, 5, 6};\nprintf(\"TechVidvan Tutorial: Basic Example of an array!\");\nprintf(\"First number is : %d\\n\",numbers[0]);\nprintf(\"Third number is : %d\\n\",numbers[2]);\nprintf(\"Last number is : %d\\n\",numbers[4]);\n}\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">TechVidvan Tutorial: Basic Example of an array!<br \/>\nFirst number is : 2<br \/>\nThird number is : 4<br \/>\nLast number is : 6<\/div>\n<h3>Change the value of array elements:-<\/h3>\n<p>In C, you can also change the elements of the array after declaring it.<\/p>\n<p><strong>Example:- Changing the value of array elements<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include&lt;stdio.h&gt;\n\nint main()\n{\nint numbers[5] = {2, 3, 4, 5, 6};\nprintf(\"TechVidvan Tutorials: Change value of array elements!\");\nnumbers[0] = 4; \/\/ changing value from 2 to 4!\nnumbers[2] = 5; \/\/ changing value from 4 to 5!\nnumbers[4] = 10; \/\/ changing value from 6 to 10!\nprintf(\"First number is : %d\\n\",numbers[0]);\nprintf(\"Third number is : %d\\n\",numbers[2]);\nprintf(\"Last number is : %d\\n\",numbers[4]);\n}\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">TechVidvan Tutorials: Change value of array elements!<br \/>\nFirst number is : 4<br \/>\nThird number is : 5<br \/>\nLast number is : 10<\/div>\n<h4>Example of array using loop:-<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\nint main () {\nint num[10]; \/\/ array of 10 elements!\nint a,b;\nprintf(\"TechVidvan Tutorials: Array using Loop!\\n\\n\");\nfor ( a = 0; a &lt; 4; a++ ) {\nnum[a] = a + 20;\n}\nfor (b = 0; b &lt; 4; b++ ) {\nprintf(\"Value of Element[%d]: %d\\n\", b, num[b] );\n}\nreturn 0;\n}\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">\n<p>TechVidvan Tutorials: Array using Loop!<\/p>\n<p>Value of Element[0]: 20<br \/>\nValue of Element[1]: 21<br \/>\nValue of Element[2]: 22<br \/>\nValue of Element[3]: 23<\/p>\n<\/div>\n<h3>Copying of arrays in C<\/h3>\n<p>In C, you can copy the elements of one array to another array.<\/p>\n<p><strong>Example:- Copying arrays in C<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\nint main(){\nfloat num1[4] = {1.5, 2.6, 3.1, 4.4};\nfloat num2[4];\nfor (int a = 0; a&lt;4; a++)\n{\n num2[a] = num1[a];\n}\nprintf(\"TechVidvan Tutorials: Copying of an array!\\n\");\nprintf(\"Copying elements of num1 array to num2 array!\\n\");\nfor (int a = 0; a&lt;4; a++)\n{\nprintf(\"Value of Element[%d]: %f\\n\",a,num2[a]); \/\/ printing elements of num2 array!\n}\n}\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">TechVidvan Tutorials: Copying of an array!<br \/>\nCopying elements of num1 array to num2 array!<br \/>\nValue of Element[0]: 1.500000<br \/>\nValue of Element[1]: 2.600000<br \/>\nValue of Element[2]: 3.100000<br \/>\nValue of Element[3]: 4.400000<\/div>\n<h3>Accessing element out of the size:-<\/h3>\n<p>Suppose, you have declared an array of 5 elements like below:-<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">int num[5];<\/pre>\n<p>You can only access the elements from num[0] to num[4].<\/p>\n<p>But let\u2019s say that you want to access the element at num[5]. This will cause errors in your code. Because the element is not available at num[5]. So, do not access elements out of its bound.<\/p>\n<h3>Arrays in Detail:-<\/h3>\n<p>A programmer should follow the below concepts while using array:-<\/p>\n<ul>\n<li><strong>Multi-dimensional Array:-<\/strong> Instead of writing a single array, you can also do a two-dimensional array.<\/li>\n<li><strong>Passing arrays to functions:-<\/strong> You can pass an array to a function by specifying the array name.<\/li>\n<li><strong>Return array from a function:-<\/strong> With the help of C, you can also return an array from a function.<\/li>\n<li><strong>Pointer to an array:-<\/strong> By specifying the name of the array, one can generate a pointer to the first element of the array.<\/li>\n<\/ul>\n<h4>Multi-dimensional Array in C<\/h4>\n<p>To put it short, with the help of a multidimensional array, you can create an array of arrays. In multidimensional arrays, data is stored in tabular format. Multidimensional arrays in C are used in computer research and analysis.<\/p>\n<p><strong>Example:- Multidimensional array:-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include&lt;stdio.h&gt;\nint main()\n{\n\/\/ array of 3 rows and 4 columns!\nint x[3][4] = {{1,2,-3}, {7,3,8}, {-1,7,5}};\nprintf(\"TechVidvan Tutorials: Accessing elements of 2d array!\");\nfor (int i = 0; i &lt; 3; i++)\n{\nfor (int j = 0; j &lt; 2; j++){\nprintf(\"Value of Element[%d][%d]: %d\\n\",i,j,x[i][j]);\n}\n}\nreturn 0;\n}\n<\/pre>\n<p><strong>Output:-<\/strong><\/p>\n<div class=\"code-output\">\n<p>TechVidvan Tutorials: Accessing elements of 2d array!<\/p>\n<p>Value of Element[0][0]: 1<br \/>\nValue of Element[0][1]: 2<br \/>\nValue of Element[1][0]: 7<br \/>\nValue of Element[1][1]: 3<br \/>\nValue of Element[2][0]: -1<br \/>\nValue of Element[2][1]: 7<\/p>\n<\/div>\n<h4>Passing arrays to function in C:-<\/h4>\n<p>You can also pass arrays to a function. Functions help programmers to divide the code into small blocks of codes and with the help of a function, you can execute those blocks of codes again and again.<\/p>\n<p>You can pass an array to a function in two ways:-<\/p>\n<p><strong>1. call by value:-<\/strong> Values of the actual parameters are copied into the function\u2019s formal parameters. And these two types of parameters are stored in different memory locations.<\/p>\n<p><strong>2. call by reference:-<\/strong> In this, the actual and formal parameters refer to the same memory locations. Any changes made into the actual parameter will affect formal parameters. To implement it, we have to use pointers.<\/p>\n<p><strong>Example:- Call by value<\/strong><\/p>\n<p>In the below example, we pass a single element to the function.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\nvoid just_print(int arr)\n{\nprintf(\"Value of the 3rd element is: %d\\n\", arr);\n}\nint main()\n{\nprintf(\"TechVidvan Tutorial: Passing a single element to a function!\\n\\n\");\nint num[5] = {1, 9, 0, 4, 5};\njust_print(num[2]); \/\/ passing a single element to the output function!\nreturn 0;\n}\n<\/pre>\n<p><strong>Output:-<\/strong><\/p>\n<div class=\"code-output\">\n<p>TechVidvan Tutorial: Passing a single element to a function!<\/p>\n<p>Value of the 3rd element is: 0<\/p>\n<\/div>\n<p><strong>In the below example, we pass the entire array to a function.<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\nvoid just_print(int num)\n{\n  printf(\"%d \", num);\n}\nint main()\n{\nprintf(\"TechVidvan Tutorial: Passing the entire array to the function!\\n\\n\");\nint i;\nint arr[] = {5,6,8,9,6};\nfor (i=0; i&lt;5; i++)\n{\njust_print(arr[i]);\n}\nreturn 0;\n}\n<\/pre>\n<p><strong>Output:-<\/strong><\/p>\n<div class=\"code-output\">\n<p>TechVidvan Tutorial: Passing the entire array to the function!<\/p>\n<p>5 6 8 9 6<\/p>\n<\/div>\n<p><strong>Example:- Call by reference<\/strong><br \/>\nIn the below example, we pass an array to the function.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\nvoid just_print(int *num)\n{\nprintf(\"%d \", *num);\n}\nint main()\n{\nprintf(\"TechVidvan Tutorial: Call by reference!\\n\\n\");\nint i;\nint arr[] = {10, 2, 48, 9};\nfor (i=0; i&lt;4; i++)\n{\njust_print(&amp;arr[i]);\n}\nreturn 0;\n}\n<\/pre>\n<p><strong>Output:-<\/strong><\/p>\n<div class=\"code-output\">\n<p>TechVidvan Tutorial: Call by reference!<\/p>\n<p>10 2 48 9<\/p>\n<\/div>\n<h4>Pointer to an array in C<\/h4>\n<p>You can also pass a pointer to an array. The main purpose of a pointer is that it allows you to access the memory of the variable to which the pointer points to. You can get the value of an entire array with the help of a pointer.<\/p>\n<p><strong>Example:- Pointer to an array<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include&lt;stdio.h&gt;\nint main()\n{\nprintf(\"TechVidvan Tutorial: Pointer to an array!\\n\\n\");\nint m;\ndouble arr[] = {4.2, 2.7, 6.2};\ndouble *point;\npoint = arr;\nprintf( \"Below is the array:\\n\");\nfor (m= 0; m &lt; 3; m++ )\n{\nprintf(\"%0.2f\\n\", *(point + m) ); \/\/ Pointer to an array\n}\nreturn 0;\n}\n<\/pre>\n<p><strong>Output:-<\/strong><\/p>\n<div class=\"code-output\">\n<p>TechVidvan Tutorial: Pointer to an array!<\/p>\n<p>Below is the array:<br \/>\n4.20<br \/>\n2.70<br \/>\n6.20<\/p>\n<\/div>\n<h4>Return array from a function in C<\/h4>\n<p>You can also return an array from a function. This technique will help you in coding.<\/p>\n<p><strong>Example:- Return array from function<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;  \nint *arr_fuc()  \n{  \nint arr_name[5];  \nprintf(\"Please Enter the elements of the array: \");  \nfor(int i=0;i&lt;5;i++)  \n{  \n  scanf(\"%d\", &amp;arr_name[i]);  \n}  \nreturn arr_name;  \n}  \nint main()  \n{  \nint *point;  \npoint=arr_fuc();  \nprintf(\"TechVidvan Tutorial: Returning array from a function!\\n\");\nprintf(\"Array is: \\n\");\nfor(int i=0;i&lt;5;i++)  \n{  \n  printf(\"%d\", point[i]);  \n}  \nreturn 0;  \n}\n<\/pre>\n<p><strong>Output:-<\/strong><\/p>\n<div class=\"code-output\">Please Enter the elements of the array: 1 2 3 4<br \/>\nTechVidvan Tutorial: Returning array from a function!<br \/>\nArray is: 1 2 3 4<\/div>\n<h3>Input\/Output Array Elements in C<\/h3>\n<p>Example of taking input from the user and storing it in an array element:-<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">\/\/ taking input and storing it in the 2nd element!\nscanf(\"%d\", &amp;num[1]);\n\/\/ taking input and storing it in the nth element!\nscanf(\"%d\", &amp;num[n-1]);\n<\/pre>\n<p>Printing individual element of an array:-<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">\/\/ printing the 2nd element of the array!\nprintf(\"%d\", num[2]);\n\n\/\/ printing the nth element of the array!\nprintf(\"%d\", num[n-1]);\n<\/pre>\n<h3>Sorting of arrays in C<\/h3>\n<p>You can also sort the arrays in ascending or descending order. It is useful for various search algorithms like Linear search, Merge sort, etc.<\/p>\n<p><strong>Example of sorting an array in C:-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include&lt;stdio.h&gt;    \nvoid main ()    \n{  \nprintf(\"TechVidvan Tutorials: Sorting of an array!\\n\\n\");\nint a, b,replace;\t \nint i[4] = { 5, 6, 9, 10};\nprintf(\"Before Sorting..\\n\");\nfor(a = 0; a&lt;4; a++){\nprintf(\"Value of Element[%d] is %d\\n\",a,i[a]);\n}\nfor(a = 0; a&lt;4; a++)    \n{\nfor(b = a+1; b&lt;4; b++)    \n{    \nif(i[b] &gt; i[a])    \n{    \nreplace = i[a]; \/\/ Sorting   \ni[a] = i[b];\t\/\/ Sorting\ni[b] = replace; \/\/ Sorting   \n}   \n}\t \n}\nprintf(\"Sorting..\\n\");\nprintf(\"After Sorting..\\n\");\nfor(a = 0; a&lt;4; a++)    \n{\nprintf(\"Value of Element[%d] is %d\\n\",a,i[a]);    \n}    \n}\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">\n<p>TechVidvan Tutorials: Sorting of an array!<\/p>\n<p>Before Sorting..<br \/>\nValue of Element[0] is 5<br \/>\nValue of Element[1] is 6<br \/>\nValue of Element[2] is 9<br \/>\nValue of Element[3] is 10<br \/>\nSorting..<br \/>\nAfter Sorting..<br \/>\nValue of Element[0] is 10<br \/>\nValue of Element[1] is 9<br \/>\nValue of Element[2] is 6<br \/>\nValue of Element[3] is 5<\/p>\n<\/div>\n<h3>Summary<\/h3>\n<p>Array is a collection of elements of the same data type. You can access any element in the array easily. Arrays are fixed in size. You cannot exceed the limit of it. Suppose, you want to store marks of 20 students then you might try to declare 20 variables like student1_marks, student2_marks etc. But what if i tell you that you can do all those with a single variable named array.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Arrays are one of the most conceptual and used features of the C programming language. It is the simplest data structure algorithm where random elements can be accessed with their index number. It is&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":82928,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3510],"tags":[3898,3899,3900,3901],"class_list":["post-81438","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c-programming","tag-arrays-in-c","tag-c-array-properties","tag-declare-arrays-in-c","tag-sorting-arrays-in-c"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Arrays in C - Properties, Syntax and Examples - TechVidvan<\/title>\n<meta name=\"description\" content=\"Array is a collection of elements of the same data type. You can access any element in the array easily. Learn more about arrays in C.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/arrays-in-c\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Arrays in C - Properties, Syntax and Examples - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Array is a collection of elements of the same data type. You can access any element in the array easily. Learn more about arrays in C.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/arrays-in-c\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-30T03:30:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/07\/Arrays-in-C.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Arrays in C - Properties, Syntax and Examples - TechVidvan","description":"Array is a collection of elements of the same data type. You can access any element in the array easily. Learn more about arrays in C.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/techvidvan.com\/tutorials\/arrays-in-c\/","og_locale":"en_US","og_type":"article","og_title":"Arrays in C - Properties, Syntax and Examples - TechVidvan","og_description":"Array is a collection of elements of the same data type. You can access any element in the array easily. Learn more about arrays in C.","og_url":"https:\/\/techvidvan.com\/tutorials\/arrays-in-c\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2021-07-30T03:30:27+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/07\/Arrays-in-C.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/arrays-in-c\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/arrays-in-c\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Arrays in C &#8211; Properties, Syntax and Examples","datePublished":"2021-07-30T03:30:27+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/arrays-in-c\/"},"wordCount":1348,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/arrays-in-c\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/07\/Arrays-in-C.jpg","keywords":["Arrays in C","C Array Properties","Declare arrays in C","Sorting arrays in C"],"articleSection":["C Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/arrays-in-c\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/arrays-in-c\/","url":"https:\/\/techvidvan.com\/tutorials\/arrays-in-c\/","name":"Arrays in C - Properties, Syntax and Examples - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/arrays-in-c\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/arrays-in-c\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/07\/Arrays-in-C.jpg","datePublished":"2021-07-30T03:30:27+00:00","description":"Array is a collection of elements of the same data type. You can access any element in the array easily. Learn more about arrays in C.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/arrays-in-c\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/arrays-in-c\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/arrays-in-c\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/07\/Arrays-in-C.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/07\/Arrays-in-C.jpg","width":1200,"height":628,"caption":"Arrays in C"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/arrays-in-c\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Arrays in C &#8211; Properties, Syntax and Examples"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/81438","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=81438"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/81438\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/82928"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=81438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=81438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=81438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}