Created
May 5, 2021 05:05
-
-
Save btechmag/4b9db1b382c35525a80bd5427efc60cb to your computer and use it in GitHub Desktop.
C Program to read an array of length 5, change the first element by the last, the second element by the fifth.
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
#include<stdio.h> | |
int main() | |
{ | |
//Program to read an array of length 5, change the first element by the last, the second element by the fifth | |
int i, j, a[10], b[10]; | |
printf("Enter 5 numbers: \n"); | |
for (i = 0; i < 5; i++) | |
{ | |
scanf("%d ", &a[i]); | |
} | |
for(i = 0, j = 4; i < 5; i++, j--) | |
{ | |
b[j] = a[i]; | |
} | |
printf("The reverse order of numbers is: \n"); | |
for(i = 0; i < 5; i++) | |
{ | |
printf("array_n[%d] = %d\n", i, b[i]); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment