Radical Developers welcomes all the visitors to be a member of the team. Come join us. Its all about open-source concept. All Programs are written and tested in MacOS X, Unix, Linux and may not match with the outputs of Turbo C++ in Windows

Sunday, January 9, 2011

Write a program to copy the contents of one array into another in the reverse order.


Source Code :

#include<stdio.h>
void main()
{
      int a[10],b[10],i,j;
      clrscr();
      printf("\nEnter Elements : ");
      for(i=0;i<10;i++)
      {
            scanf("%d",&a[i]);
      }
      for(i=0,j=9;i<10;i++,j--)
      {
            b[i]=a[j];
      }
      printf("\nArray after Copying in Reverse Order : ");
      for(i=0;i<10;i++)
      {
            printf("%d ",b[i]);
      }
      getch();
}

Output :

Enter Elements : 2 6 3 5 9 8 7 4 1 0

Array after Copying in Reverse Order : 0 1 4 7 8 9 5 3 6 2

No comments:

Post a Comment