Created
July 27, 2018 17:19
-
-
Save krishnaprajapat/cd06dc931fcbd66a255e000eb96028f9 to your computer and use it in GitHub Desktop.
Array using tower of Hanoi in c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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