Created
July 1, 2017 04:16
-
-
Save Rafi993/7cb808e75e1d4ff22c1fe090a6a655ca to your computer and use it in GitHub Desktop.
null created by Rafi993 - https://repl.it/JJd8/0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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