Chapter - 9: Arrays

Write a program to copy the contents of one array into another in the reverse order.


I
Sections
1
Exercises

A

B

C

D

E

F

G

H

I

J

K

L

1

2

3

4

#include<stdio.h>
#include<conio.h>
int main()
{
	int ar1[5] = { 10,20,30,40,50 }, ar2[5], i;

	//copying elements
	for (i = 4; i >= 0; i--)
		ar2[i] = ar1[4 - i];

	//displaying array
	for (i = 0; i < 5; i++)
		printf("%d ", ar2[i]);

	_getch();
	return 0;
}

© 2020 Garbage Valuegarbage value logo