Skip to content

Instantly share code, notes, and snippets.

@Rafi993
Created July 1, 2017 04:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rafi993/7cb808e75e1d4ff22c1fe090a6a655ca to your computer and use it in GitHub Desktop.
Save Rafi993/7cb808e75e1d4ff22c1fe090a6a655ca to your computer and use it in GitHub Desktop.
null created by Rafi993 - https://repl.it/JJd8/0
/*C program that declares an array A and inputs n integer values in A.
Then the contents of array A is copied to another array B in reversed order.
Finally print the elements of array B*/
#include<stdio.h>
int main()
{
int n, reverse, i ;
int A[100], B[100] ;
printf("Input the size of array A: ") ;
scanf("%d", &n ) ;
printf("Input the values of A: ") ;
for( i = 0 ; i<n ; i++ )
scanf("%d ", &A[i] ) ;
for(i = n-1 , reverse = 0 ; i>= 0 ; i--, reverse++)
B[reverse] = A[i] ;
for(i = 0 ; i<n ; i++ )
A[i] = B[i];
printf("Array B: ") ;
for(i=0 ; i<n ; i++ )
printf("%d ", A[i] ) ;
return 0 ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment