My  iterative approach

/*code in c*/
#include<stdio.h>
int main()
{
 int stack[]={1,2,3,4,5,6,7,8},top=7;//
 int i,j,temp;

 for(i=1;i<=top;i++)
 { 
  temp=stack[i];
 
  for(j=i;j>0;j--)
    stack[j]=stack[j-1];

  stack[0]=temp;
 }

 for(i=0;i<=top;i++)
   printf("%d ",stack[i] );

 return 0;
}
 /*


Rituraj
2nd Yr.
B.tech CSE
NIT -Trichy

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/n1OE58e8B7IJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to