Skip to content

Instantly share code, notes, and snippets.

@btechmag
Created May 5, 2021 05:05
Show Gist options
  • Save btechmag/4b9db1b382c35525a80bd5427efc60cb to your computer and use it in GitHub Desktop.
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.
#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