Copy one array into another in Reverse Order

This is C program to demonstrate how to copy one array into another in reverse order.

 

You can compile this program on bOtskOOl Free Online C/C++ Compiler

 

 

SOURCE CODE

 

//A C example to Copy one array into another in Reverse Order

 

//***********************

//www.botskool.com

//***********************

 

#include<stdio.h>

#include<conio.h>

void main()

{

int i,n=10,a[20],b[20];

clrscr();

printf("How many element do you wish to enter in array? :"); scanf("%d",&n);


printf("\nEnter the Elements:\n");

for(i=0;i<n;i++)

{

printf("Enter Element No %d : ",1+i);                

scanf("%d",&a[i]);

}

printf("\n Original ARRAY: \n");

for(i=0;i<n;i++)

printf(" %d ",a[i]);


for(i=0;i<n;i++)

{

                b[n-1-i]=a[i];

}

 


printf("\n Copied ARRAY: \n");

for(i=0;i<n;i++)

printf(" %d ",b[i]);


getch();

}

 

//***********************

//www.botskool.com

//***********************

Output will look like this:

Output - Copy one array into another in Reverse Order

 

Download source code.

 
Terms of Agreement:  
By using this code, you agree to the following terms-  
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.  
2) You MAY NOT redistribute this code (for example to a web site) without written permission from us. Failure to do so is a violation of copyright laws.  
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame.
4) You will abide by any additional copyright restrictions which may have placed in the code or code's description.
 >>Kindly post your doubts and suggestions on our discussion forum.
Tags: