<?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>Towers of Hanoi | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/towers-of-hanoi/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Sat, 09 Jun 2012 16:55:20 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>
	<item>
		<title>C Program for Binary Search and Towers of Hanoi using Recursion</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/c-advanced/c-program-for-binary-search-and-towers-of-hanoi-using-recursion/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/c-advanced/c-program-for-binary-search-and-towers-of-hanoi-using-recursion/#respond</comments>
		
		<dc:creator><![CDATA[Ansten Lobo]]></dc:creator>
		<pubDate>Sat, 09 Jun 2012 16:55:20 +0000</pubDate>
				<category><![CDATA[Advanced programs]]></category>
		<category><![CDATA[c program]]></category>
		<category><![CDATA[recursion]]></category>
		<category><![CDATA[binary search]]></category>
		<category><![CDATA[Towers of Hanoi]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=3319</guid>

					<description><![CDATA[<p>C Program for Binary Search and Towers of Hanoi using Recursion. Source: Dr. G T Raju, Professor &#038; Head, Dept. of CSE, RNSIT main() { int n,a[50],key,opn,i,pos; do { clrscr(); printf(" \n\n Press 1 -> Binary Search , 2-> Towers of Hanoi 3-> Quit\n"); scanf("%d",&#038;opn); switch(opn) { case 1: printf(" How Many Elements?"); scanf("%d",&#038;n); printf("</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/c-advanced/c-program-for-binary-search-and-towers-of-hanoi-using-recursion/">C Program for Binary Search and Towers of Hanoi using Recursion</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>C Program for Binary Search and Towers of Hanoi using Recursion.<br />
Source: Dr. G T Raju, Professor &#038; Head, Dept. of CSE, RNSIT</p>
<pre lang="C" line="1">
main()
{
    int n,a[50],key,opn,i,pos;
    do
    {
        clrscr();
        printf(" \n\n Press 1 -> Binary Search , 2-> Towers of Hanoi 3-> Quit\n");
        scanf("%d",&opn);
        switch(opn)
        {
        case 1: printf(" How Many Elements?");
            scanf("%d",&n);
            printf(" Read all the elements is ASC order \n");
            for(i=1;i<=n;i++)
                scanf("%d",&#038;a[i]);
            printf(" Read the Key Element\n");
            scanf("%d",&#038;key);
            pos=BS(a,key,1,n);
            if(pos)	 printf(" Success: %d found at %d \n", key,pos);
            else	 printf(" Falure: %d Not found in the list ! \n",key);
            break;
        case 2: printf("\n\n How Many Disks ?");
            scanf("%d", &#038;n);
            printf("\n\n Result of Towers of Hanoi for %d Disks \n",n);
            tower(n,'A','B','C');
            printf("\n\n Note: A-> Source, B-> Intermediate, C-> Destination\n");
            break;
        case 3: printf(" Terminating \n"); break;
        default: printf(" Invalid Option !! Try Again !! \n");
        }
        printf(" Press a Key. . . ");  getch();
    }while(opn != 3);
}
int BS(int a[], int key,int low,int high)
{
    int mid;
    if(low > high) return 0; /* failure */
    else
    {
        mid=(low+high)/2;
        if(a[mid]== key) return mid; /* Success */
        if(key < a[mid]) return(BS(a,key,low,mid-1));
        return(BS(a,key,mid+1,high));
    }
}
tower(int n, char src, char intr, char dst)
{
    if(n > 0)
    {
        tower(n-1,src,dst,intr);
        printf("Move disk %d from %c to %c \n", n,src,dst);
        tower(n-1,intr,src,dst);
    }
}
</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/c-advanced/c-program-for-binary-search-and-towers-of-hanoi-using-recursion/">C Program for Binary Search and Towers of Hanoi using Recursion</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/c-tutorials/c/c-advanced/c-program-for-binary-search-and-towers-of-hanoi-using-recursion/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
