I have a problem with rotating an array and assigning it to different variables. Please help me with this. This is wat i have done. I am a novice and please help me in this.
Code:#include<stdio.h>#include<stdlib.h> #include<conio.h> #include<math.h> int n[16],a[16],n1[16],n2[16],n3[16],n4[16],n5[16],n6[16],n7[16],n8[16],n9[16],n10[16],n11[16],n12[16],n13[16],n14[16],n15[16],n16[16], c=0; int x[16],i,j,k; int rotate(); main() { printf("Enter the input \n"); for(i=0;i<16;i++) { scanf("%d",&a[i]); } for(i=0;i<16;i++) { printf("%d",a[i]); } for(i=0;i<16;i++) { int p=rotate(); } getch(); } int rotate() { printf("\nThe array is now rotated by\n"); scanf("%d",&j); for(c=0;c<j;c++) { while(c<j) { k=a[0]; for(i=0;i<16;i++) { a[i]=a[i+1]; } a[15]=k; c++; } } printf("Rotated array is\n"); for(i=0;i<16;i++) { printf("%d",a[i]); } }



LinkBack URL
About LinkBacks



