<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>StudyStreet.com</title>
	<atom:link href="http://www.studystreet.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.studystreet.com</link>
	<description>Your encyclopedia to programming</description>
	<lastBuildDate>Wed, 21 Nov 2012 13:42:35 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5</generator>
		<item>
		<title>Find the number of even/odd integers in an array</title>
		<link>http://www.studystreet.com/even-odd-integers/</link>
		<comments>http://www.studystreet.com/even-odd-integers/#comments</comments>
		<pubDate>Wed, 21 Nov 2012 13:41:19 +0000</pubDate>
		<dc:creator>kaliadevansh</dc:creator>
				<category><![CDATA[C program code examples]]></category>
		<category><![CDATA[C programming]]></category>

		<guid isPermaLink="false">http://www.studystreet.com/?p=1125</guid>
		<description><![CDATA[To know the number of even/odd numbers, we use the modulus function. &#8216;%&#8217; The program is: #include&#60;stdio.h&#62; #include&#60;conio.h&#62; #define MAX 99 main() { int a[MAX],i,n,even,odd; printf(&#34;Enter the number of elements in the array\n&#34;); scanf(&#34;%d&#34;,&#38;n); printf(&#34;Enter the elements&#34;); for(i=0;i&#60;n;i++) scanf(&#34;%d&#34;,&#38;a[i]); even=0; odd=0; for(i=0;i&#60;n;i++) { if(a[i]%2==0) even++; else if(a[i]%2!=0) odd++; } printf(&#34;The number of even elements are:%d\nThe [...]]]></description>
				<content:encoded><![CDATA[            <script type="text/javascript" src="http://www.studystreet.com/wp-content/plugins/wordpress-code-snippet/scripts/shBrushCpp.js"></script>
<p>To know the number of even/odd numbers, we use the modulus function. &#8216;%&#8217;<br />
The program is:</p>
<p><span id="more-1125"></span><br />
<pre class="brush: cpp">#include&lt;stdio.h&gt;
#include&lt;conio.h&gt;
#define MAX 99
main()
{
 int a[MAX],i,n,even,odd;
 printf(&quot;Enter the number of elements in the array\n&quot;);
 scanf(&quot;%d&quot;,&amp;n);
 printf(&quot;Enter the elements&quot;);
 for(i=0;i&lt;n;i++)
  scanf(&quot;%d&quot;,&amp;a[i]);
 even=0;
 odd=0;
 for(i=0;i&lt;n;i++)
 {
  if(a[i]%2==0)
   even++;
  else if(a[i]%2!=0)
   odd++;
 }
 printf(&quot;The number of even elements are:%d\nThe number of odd elements are:%d&quot;,even,odd);
 getch();
 }</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://www.studystreet.com/even-odd-integers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Binary Search</title>
		<link>http://www.studystreet.com/binary-search/</link>
		<comments>http://www.studystreet.com/binary-search/#comments</comments>
		<pubDate>Tue, 28 Aug 2012 12:44:39 +0000</pubDate>
		<dc:creator>kaliadevansh</dc:creator>
				<category><![CDATA[C program code examples]]></category>
		<category><![CDATA[C programming]]></category>

		<guid isPermaLink="false">http://www.studystreet.com/?p=1111</guid>
		<description><![CDATA[Binary Search algorithm reduces the time complexity of the searching algorithm. #include&#60;stdio.h&#62; #include&#60;conio.h&#62; void main() { int i,fiirst,last,middle,n,search,a[10]; printf(&#34;Enter the no. of elements&#34;); scanf(&#34;%d&#34;,&#38;n); printf(&#34;Enter the elements&#34;); for(i=0;i&#60;n;i++) scanf(&#34;%d&#34;,&#38;array[i]); printf(&#34;Enter the value to find&#34;); scanf(&#34;%d&#34;,&#38;search); first=0; last=n-1; middle=(first+last)/2; while(first&#60;=last) { if(array[middle]&#60;search) { first=middle+1; } else if(array[middle]==search) { printf(&#34;Element found at location %d&#34;,middle); break; } else [...]]]></description>
				<content:encoded><![CDATA[            <script type="text/javascript" src="http://www.studystreet.com/wp-content/plugins/wordpress-code-snippet/scripts/shBrushCpp.js"></script>
<p>Binary Search algorithm reduces the time complexity of the searching algorithm.<br />
<span id="more-1111"></span> <pre class="brush: cpp">#include&lt;stdio.h&gt;
#include&lt;conio.h&gt;
void main()
{
int i,fiirst,last,middle,n,search,a[10];
printf(&quot;Enter the no. of elements&quot;);
scanf(&quot;%d&quot;,&amp;n);
printf(&quot;Enter the elements&quot;);
for(i=0;i&lt;n;i++)
  scanf(&quot;%d&quot;,&amp;array[i]);
printf(&quot;Enter the value to find&quot;);
scanf(&quot;%d&quot;,&amp;search);
first=0;
last=n-1;
middle=(first+last)/2;
while(first&lt;=last)
{
if(array[middle]&lt;search)
{
first=middle+1;
}
else if(array[middle]==search)
{
printf(&quot;Element found at location %d&quot;,middle);
break;
}
else
{
last=middle-1;
middle=(first+last)/2;
}
if(first&gt;last)
  printf(&quot;Element not found&quot;);
getch();
}</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://www.studystreet.com/binary-search/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Insertion Sort using C</title>
		<link>http://www.studystreet.com/insertion-sort/</link>
		<comments>http://www.studystreet.com/insertion-sort/#comments</comments>
		<pubDate>Tue, 28 Aug 2012 12:42:29 +0000</pubDate>
		<dc:creator>kaliadevansh</dc:creator>
				<category><![CDATA[C program code examples]]></category>
		<category><![CDATA[C programming]]></category>

		<guid isPermaLink="false">http://www.studystreet.com/?p=1112</guid>
		<description><![CDATA[This program represents the implementation of Insertion Sort using C language: #include&#60;stdio.h&#62; #include&#60;conio.h&#62; void main() { int a[20],n,t,i,j; printf(&#34;\nEnter the no. of elements&#34;); scanf(&#34;%d&#34;,&#38;n); printf(&#34;\nEnter the elements of array&#34;); for(i=0;i&#60;n;i++) scanf(&#34;%d&#34;,&#38;a[i]); for(i=1;i&#60;n;i++) { t=a[i]; j=i-1; while(t&#60;a[j]&#38;&#38;j&#62;=0) { a[j+1]=a[j]; j=j-1; } a[j+1]=t; } printf(&#34;Ascending order of sorted list is:&#34;); for(i=0;i&#60;n;i++) printf(&#34;\n%d&#34;,a[i]); getch(); }]]></description>
				<content:encoded><![CDATA[            <script type="text/javascript" src="http://www.studystreet.com/wp-content/plugins/wordpress-code-snippet/scripts/shBrushCpp.js"></script>
<p>This program represents the implementation of Insertion Sort using C language:<br />
<span id="more-1112"></span> <pre class="brush: cpp">#include&lt;stdio.h&gt;
#include&lt;conio.h&gt;
void main()
{
int a[20],n,t,i,j;
printf(&quot;\nEnter the no. of elements&quot;);
scanf(&quot;%d&quot;,&amp;n);
printf(&quot;\nEnter the elements of array&quot;);
for(i=0;i&lt;n;i++)
  scanf(&quot;%d&quot;,&amp;a[i]);
for(i=1;i&lt;n;i++)
{
t=a[i];
j=i-1;
while(t&lt;a[j]&amp;&amp;j&gt;=0)
{
a[j+1]=a[j];
j=j-1;
}
a[j+1]=t;
}
printf(&quot;Ascending order of sorted list is:&quot;);
for(i=0;i&lt;n;i++)
  printf(&quot;\n%d&quot;,a[i]);
getch();
}</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://www.studystreet.com/insertion-sort/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Selection Sort using C</title>
		<link>http://www.studystreet.com/selection-sort/</link>
		<comments>http://www.studystreet.com/selection-sort/#comments</comments>
		<pubDate>Tue, 28 Aug 2012 12:40:32 +0000</pubDate>
		<dc:creator>kaliadevansh</dc:creator>
				<category><![CDATA[C program code examples]]></category>
		<category><![CDATA[C programming]]></category>

		<guid isPermaLink="false">http://www.studystreet.com/?p=1109</guid>
		<description><![CDATA[The following C program represents how Selection Sort Algorithm can be implemented. #include&#60;stdio.h&#62; #include&#60;conio.h&#62; void main() { int a[10],n,j,i,k,t; printf(&#34;Enter the number of elements in the array&#34;); scanf(&#34;%d&#34;,&#38;n); printf(&#34;Enter the elements to be sorted&#34;); for(i=0;i&#60;n;i++) scanf(&#34;%d&#34;,&#38;a[i]); for(j=0;j&#60;n-1;j++) { for(k=j+1;k&#60;=n;k++) { if(a[j]&#62;a[k]) { t=a[j]; a[j]=a[k]; a[k]=t; } } } printf(&#34;The sorted list is:&#34;); for(i=0;i&#60;n;i++) { pritnf(&#34;%d&#34;,a[i]); [...]]]></description>
				<content:encoded><![CDATA[            <script type="text/javascript" src="http://www.studystreet.com/wp-content/plugins/wordpress-code-snippet/scripts/shBrushCpp.js"></script>
<p>The following C program represents how Selection Sort Algorithm can be implemented.<br />
<span id="more-1109"></span><pre class="brush: cpp">#include&lt;stdio.h&gt;
#include&lt;conio.h&gt;
void main()
{
int a[10],n,j,i,k,t;
printf(&quot;Enter the number of elements in the array&quot;);
scanf(&quot;%d&quot;,&amp;n);
printf(&quot;Enter the elements to be sorted&quot;);
for(i=0;i&lt;n;i++)
 scanf(&quot;%d&quot;,&amp;a[i]);
for(j=0;j&lt;n-1;j++)
{
 for(k=j+1;k&lt;=n;k++)
 {
  if(a[j]&gt;a[k])
  {
   t=a[j];
   a[j]=a[k];
   a[k]=t;
  }
 }
}
printf(&quot;The sorted list is:&quot;);
for(i=0;i&lt;n;i++)
{
pritnf(&quot;%d&quot;,a[i]);
}
getch();
}</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://www.studystreet.com/selection-sort/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bubble Sort using C</title>
		<link>http://www.studystreet.com/bubble-sort-using-c/</link>
		<comments>http://www.studystreet.com/bubble-sort-using-c/#comments</comments>
		<pubDate>Tue, 28 Aug 2012 12:39:02 +0000</pubDate>
		<dc:creator>kaliadevansh</dc:creator>
				<category><![CDATA[C program code examples]]></category>
		<category><![CDATA[C programming]]></category>

		<guid isPermaLink="false">http://www.studystreet.com/?p=1106</guid>
		<description><![CDATA[This program shows the implementation of Bubble Sort using C: #include&#60;stdio.h&#62; #include&#60;conio.h&#62; void main() { int a[5],i,j,t,n.k; printf(&#34;Enter the no. of elements:&#34;); scanf(&#34;%d&#34;,&#38;n); printf(&#34;Enter the element of the array:&#34;,n); for(i=0;i&#60;n;i++) { scanf(&#34;%d&#34;,&#38;a[i]); } for(j=0;j&#60;n;j++) { for(k=0;k&#60;n-j-1;k++) { if(a[k]&#62;a[k+1]) { t=a[k]; a[k]=a[k+1]; a[k+1]=t; } } } printf(&#34;Sorted list is:&#34;); for(i=0;i&#60;n;i++) printf(&#34;%d&#34;,a[i]); getch(); }]]></description>
				<content:encoded><![CDATA[            <script type="text/javascript" src="http://www.studystreet.com/wp-content/plugins/wordpress-code-snippet/scripts/shBrushCpp.js"></script>
<p>This program shows the implementation of Bubble Sort using C:</p>
<p><span id="more-1106"></span><br />
<pre class="brush: cpp">#include&lt;stdio.h&gt;
#include&lt;conio.h&gt;
void main()
{
 int a[5],i,j,t,n.k;
 printf(&quot;Enter the no. of elements:&quot;);
 scanf(&quot;%d&quot;,&amp;n);
 printf(&quot;Enter the element of the array:&quot;,n);
 for(i=0;i&lt;n;i++)
 {
  scanf(&quot;%d&quot;,&amp;a[i]);
 }
 for(j=0;j&lt;n;j++)
 {
  for(k=0;k&lt;n-j-1;k++)
  {
   if(a[k]&gt;a[k+1])
   {
    t=a[k];
    a[k]=a[k+1];
    a[k+1]=t;
   }
  }
 }
 printf(&quot;Sorted list is:&quot;);
 for(i=0;i&lt;n;i++)
 printf(&quot;%d&quot;,a[i]);
 getch();
}</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://www.studystreet.com/bubble-sort-using-c/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>C program to merge two sorted arrays</title>
		<link>http://www.studystreet.com/c-program-merge-sorted-arrays/</link>
		<comments>http://www.studystreet.com/c-program-merge-sorted-arrays/#comments</comments>
		<pubDate>Mon, 09 Jul 2012 16:59:39 +0000</pubDate>
		<dc:creator>yashan</dc:creator>
				<category><![CDATA[C program code examples]]></category>

		<guid isPermaLink="false">http://www.studystreet.com/?p=1085</guid>
		<description><![CDATA[Program in the C programming language to merge two sorted arrays. Note that after this code is compiled, the elements of the arrays should be entered  in the ascending order as the program is made according to it. Below is the code of the C program - /* C Program to Merge Two Sorted Arrays [...]]]></description>
				<content:encoded><![CDATA[            <script type="text/javascript" src="http://www.studystreet.com/wp-content/plugins/wordpress-code-snippet/scripts/shBrushCpp.js"></script>
<p>Program in the C programming language to merge two sorted arrays. Note that after this code is compiled, the elements of the arrays should be entered  in the ascending order as the program is made according to it. Below is the code of the C program -<span id="more-1085"></span></p>
<p><pre class="brush: cpp">/* C Program to Merge Two Sorted Arrays */

#include &lt;stdio.h&gt;
void main()
{
     int a[50], b[50], c[100], m, n, i, j, k=0;
     printf(&quot;\nEnter size of array A: &quot;);
     scanf(&quot;%d&quot;, &amp;m);
     printf(&quot;\nEnter sorted elements of array A:\n&quot;);
     for(i=0; i&lt;m; i++)
     {
              scanf(&quot;%d&quot;, &amp;a[i]);
     }
     
     printf(&quot;\nEnter size of array B: &quot;);
     scanf(&quot;%d&quot;, &amp;n);
     printf(&quot;\nEnter sorted elements of array B:\n&quot;);
     for(i=0; i&lt;n; i++)
     {
              scanf(&quot;%d&quot;, &amp;b[i]);
     }
     
     i=0;
     j=0;
     while(i&lt;m &amp;&amp; j&lt;n)
     {
               if(a[i] &lt; b[j])
               {
                       c[k] = a[i];
                       i++;
               }
               else
               {
                   c[k] = b[j];
                   j++;
               }
               k++;
     }
     
     if(i &gt;= m)
     {
          while(j&lt;n)
          {
                    c[k] = b[j];  
                    j++;
                    k++;
          }
     }
     
     if(j &gt;= n)
     {
          while(i&lt;m)
          {
                    c[k] = a[i];
                    i++;
                    k++;
          }
     }
     
     printf(&quot;\nAfter merging:\n&quot;);
     for(i=0; i&lt;m+n; i++)
     {
              printf(&quot;\n%d&quot;, c[i]);
     }
     getch();
}
</pre></p>
<pre><strong>Input</strong>-
Enter size of array A: 5
Enter sorted elements of array A:
2    6    15    23    35

Enter size of array B: 4
Enter sorted elements of array B:
7    13    14    39

<strong>Output-</strong>
After merging the elements are:
2    6    7    13    14    15    23    35    39</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.studystreet.com/c-program-merge-sorted-arrays/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Secant Method</title>
		<link>http://www.studystreet.com/secant-method/</link>
		<comments>http://www.studystreet.com/secant-method/#comments</comments>
		<pubDate>Tue, 12 Jun 2012 15:59:28 +0000</pubDate>
		<dc:creator>kaliadevansh</dc:creator>
				<category><![CDATA[C program code examples]]></category>

		<guid isPermaLink="false">http://www.studystreet.com/?p=1093</guid>
		<description><![CDATA[Secant Method is a method to find the roots of a function f. For coding, we define the function f in a separate code and then use it accordingly. The C code for this method is: #include&#60;stdio.h&#62; #include&#60;conio.h&#62; #include&#60;math.h&#62; float f(float x) { return(2*x-log10(x)-6); } void main() { float x,x1,a,b,err=0.00005; int itr=1,n; clrscr(); printf(&#34;enter the [...]]]></description>
				<content:encoded><![CDATA[            <script type="text/javascript" src="http://www.studystreet.com/wp-content/plugins/wordpress-code-snippet/scripts/shBrushCpp.js"></script>
<p>Secant Method is a method to find the roots of a function f.<br />
For coding, we define the function f in a separate code and then use it accordingly.<br />
The C code for this method is:<span id="more-1093"></span><br />
<pre class="brush: cpp">#include&lt;stdio.h&gt;
#include&lt;conio.h&gt;
#include&lt;math.h&gt;
float f(float x)
{
return(2*x-log10(x)-6);
}
void main()
{
float x,x1,a,b,err=0.00005;
int itr=1,n;
clrscr();
printf(&quot;enter the values of a,b and maximum iterations\n&quot;);
scanf(&quot;%f%f%d&quot;,&amp;a,&amp;b,&amp;n);
x=b-(((b-a)/(f(b)-f(a)))*f(b));
printf(&quot;iteration no. %d\tx=%f\n&quot;,itr,x);
itr++;
while(itr&lt;n)
{
a=b;
b=x;
x=b-(((b-a)/(f(b)-f(a)))*f(b));
printf(&quot;iteration no. %d\tx=%f\n&quot;,itr,x);
if(fabs(x1-x)&lt;err)
{
printf(&quot;\nafter %d iterations, the value of root is %f\n&quot;,itr,x);
break;
}
else
itr++;
x1=x;
}
if(itr==n)
printf(&quot;\nsolution does not exist as iterations are not sufficient&quot;);
getch();
return 0;
}</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://www.studystreet.com/secant-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Program in C to transpose a 2D array</title>
		<link>http://www.studystreet.com/program-c-transpose-2d-array/</link>
		<comments>http://www.studystreet.com/program-c-transpose-2d-array/#comments</comments>
		<pubDate>Sat, 19 May 2012 11:30:51 +0000</pubDate>
		<dc:creator>yashan</dc:creator>
				<category><![CDATA[C program code examples]]></category>

		<guid isPermaLink="false">http://www.studystreet.com/?p=1081</guid>
		<description><![CDATA[Transpose means changing the rows of 2D array into columns and columns into rows. Below is the code in the C programming language to transpose a two dimensional array - /* C program to transpose the 2D array */ #include&#60;stdio.h&#62; void main() { int a[10][10], b[10][10], m, n, i, j; printf(&#34;\nEnter number of rows &#38; [...]]]></description>
				<content:encoded><![CDATA[            <script type="text/javascript" src="http://www.studystreet.com/wp-content/plugins/wordpress-code-snippet/scripts/shBrushCpp.js"></script>
<p>Transpose means changing the rows of 2D array into columns and columns into rows. Below is the code in the C programming language to transpose a two dimensional array -<span id="more-1081"></span></p>
<p><pre class="brush: cpp">/* C program to transpose the 2D array */

#include&lt;stdio.h&gt;

void main()
{
     int a[10][10], b[10][10], m, n, i, j;
     
     printf(&quot;\nEnter number of rows &amp; columns of aray : &quot;);
     scanf(&quot;%d %d&quot;, &amp;m, &amp;n);
     
     printf(&quot;\nEnter elements of 2-D array:\n&quot;);
     for(i=0; i&lt;m; i++)
     {
              for(j=0; j&lt;n; j++)
              {
                       scanf(&quot;%d&quot;, &amp;a[i][j]);
              }
     }
     
     printf(&quot;\n\n2-D array before transposing:\n\n&quot;);
     for(i=0; i&lt;m; i++)
     {
              for(j=0; j&lt;n; j++)
              {
                       printf(&quot;\t%d&quot;, a[i][j]);
              }
              printf(&quot;\n\n&quot;);
     }
     
     /* Transposing array */
     for(i=0; i&lt;m; i++)
     {
              for(j=0; j&lt;n; j++)
              {
                       b[j][i] = a[i][j];
              }
     }
     
     printf(&quot;\n\n2-D array after transposing:\n\n&quot;);
     for(i=0; i&lt;n; i++)
     {
              for(j=0; j&lt;m; j++)
              {
                       printf(&quot;\t%d&quot;, b[i][j]);
              }
              printf(&quot;\n\n&quot;);
     }
     getch();
}</pre></p>
<p>We create the 2D array first and after that it&#8217;s transpose is done which is stored in new 2D array. Hence the result is printed.<br />
<strong>Input- </strong><br />
Enter number of rows &amp; columns of aray : 3 x 3<br />
Enter elements of 2-D array:<br />
25   12   4   62   34   23   6   4   3</p>
<p><strong>Output-</strong><br />
2-D array before transposing:</p>
<p>25   12  4</p>
<p>62   34  23</p>
<p>6     4     3</p>
<p>2-D array after transposing:</p>
<p>25   62   6</p>
<p>12   34   4</p>
<p>4    23    3</p>
]]></content:encoded>
			<wfw:commentRss>http://www.studystreet.com/program-c-transpose-2d-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C program to delete an element from the array</title>
		<link>http://www.studystreet.com/data-structure-program-delete-element-array/</link>
		<comments>http://www.studystreet.com/data-structure-program-delete-element-array/#comments</comments>
		<pubDate>Fri, 18 May 2012 11:30:53 +0000</pubDate>
		<dc:creator>yashan</dc:creator>
				<category><![CDATA[C program code examples]]></category>

		<guid isPermaLink="false">http://www.studystreet.com/?p=1076</guid>
		<description><![CDATA[Data structure&#8217;s C program to delete an element from the array. Enter the array size and then it&#8217;s elements. After this enter the location of the element you want to delete and the item will be deleted. Below is the code of the above program /* Program in C to delete an element from the [...]]]></description>
				<content:encoded><![CDATA[            <script type="text/javascript" src="http://www.studystreet.com/wp-content/plugins/wordpress-code-snippet/scripts/shBrushCpp.js"></script>
<p>Data structure&#8217;s C program to delete an element from the array. Enter the array size and then it&#8217;s elements. After this enter the location of the element you want to delete and the item will be deleted. Below is the code of the above program<span id="more-1076"></span></p>
<p><pre class="brush: cpp">/* Program in C to delete an element from the array */

#include&lt;stdio.h&gt;

void main()
{
     int a[20], n, loc, item,i;
     
     printf(&quot;\nEnter size of an array: &quot;);
     scanf(&quot;%d&quot;, &amp;n);

     printf(&quot;\nEnter elements of an array:\n&quot;);
     for(i=0; i&lt;n; i++)
     {
              scanf(&quot;%d&quot;, &amp;a[i]);
     }
     
     printf(&quot;\nEnter location of deletion: &quot;);
     scanf(&quot;%d&quot;, &amp;loc);
     
     item = a[loc-1];
     for(i=loc-1; i&lt;n; i++)
     {
              a[i] = a[i+1];
     }
     n--;
     printf(&quot;\nITEM deleted: %d&quot;, item);
     
     printf(&quot;\n\nAfter deletion:\n&quot;);
     for(i=0; i&lt;n; i++)
     {
              printf(&quot;\n%d&quot;, a[i]);
     }
     getch();
}
</pre></p>
<p><strong>Input -</strong><br />
Enter array size &#8211; 5<br />
Enter array elements &#8211; 5   2    15    50    23<br />
Enter Location of element to be deleted &#8211; 4</p>
<p><strong>Output-</strong><br />
Array after deletion is  - 5   2   15   23</p>
]]></content:encoded>
			<wfw:commentRss>http://www.studystreet.com/data-structure-program-delete-element-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C program to insert an element in the sorted array</title>
		<link>http://www.studystreet.com/insert-item-sorted-array/</link>
		<comments>http://www.studystreet.com/insert-item-sorted-array/#comments</comments>
		<pubDate>Wed, 16 May 2012 07:07:01 +0000</pubDate>
		<dc:creator>yashan</dc:creator>
				<category><![CDATA[C program code examples]]></category>

		<guid isPermaLink="false">http://www.studystreet.com/?p=1071</guid>
		<description><![CDATA[Insertion is one of the operations performed on the arrays. So below is the program in C language to insert an element / item in the sorted array - /* Program in C to insert the element in the sorted array */ #include&#60;stdio.h&#62; void main( ) { int a[20],n,item,i; printf(&#34;Enter the size of the array&#34;); [...]]]></description>
				<content:encoded><![CDATA[            <script type="text/javascript" src="http://www.studystreet.com/wp-content/plugins/wordpress-code-snippet/scripts/shBrushCpp.js"></script>
<p>Insertion is one of the operations performed on the arrays. So below is the program in C language to insert an element / item in the sorted array -<span id="more-1071"></span></p>
<p><pre class="brush: cpp">/*  Program in C to insert the element in the sorted array  */

#include&lt;stdio.h&gt;
void main( )
{
     int a[20],n,item,i;
     
     printf(&quot;Enter the size of the array&quot;);
     scanf(&quot;%d&quot;,&amp;n);
     
     printf(&quot;Enter elements of the array in the sorted order&quot;);
     for(i=0; i&lt;n; i++)
     {
            scanf(&quot;%d&quot;, &amp;a[i]);
     }
     
     printf(&quot;\nEnter ITEM to be inserted : &quot;);
     scanf(&quot;%d&quot;, &amp;item);
     
     i = n-1;
     while(item&lt;a[i] &amp;&amp; i&gt;=0)
     {
           a[i+1] = a[i];
           i--;
     }
     a[i+1] = item;
     n++;
     
     printf(&quot;\n\nAfter insertion array is :\n&quot;);
     for(i=0; i&lt;n; i++)
     {
              printf(&quot;\n%d&quot;, a[i]);
     }
     getch();
}    </pre></p>
<p><strong>Note</strong> that the array elements to be entered in the array should be in the ascending order. As the program to made according to it. After that enter the item to be inserted and the while loop will check where the item should be inserted. It will insert the item according to the sorted ascending order.</p>
<p><strong>Input -</strong><br />
Enter the number of elements in the array &#8211; 5<br />
Array Elements &#8211; 5   15   25   50   52<br />
Enter the element to be inserted &#8211; 17</p>
<p><strong>Output -</strong><br />
Sorted array after insertion :<br />
5   15   <strong>17</strong>   25   50   52</p>
]]></content:encoded>
			<wfw:commentRss>http://www.studystreet.com/insert-item-sorted-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
