Skip to content

Instantly share code, notes, and snippets.

@krishnaprajapat
Created July 27, 2018 17:19
Show Gist options
  • Save krishnaprajapat/cd06dc931fcbd66a255e000eb96028f9 to your computer and use it in GitHub Desktop.
Save krishnaprajapat/cd06dc931fcbd66a255e000eb96028f9 to your computer and use it in GitHub Desktop.
Array using tower of Hanoi in c
#include<stdio.h>
int main()
{
int i,a[10],b[10],c[10],n;
printf("enter array size");
scanf("%d",&n);
printf("\n enter array element");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
if(n==1)
{
c[0]=a[0];
printf("\n array is:");
printf("%d",c[0]);
}
else
{
for(i=0;i<n-1;i++)
b[i]=a[i];
c[n-1]=a[n-1];
for(i=0;i<n-1;i++)
c[i]=b[i];
printf("\n array is:");
for(i=0;i<n;i++)
printf("\n%d",c[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment