forked from sachin-nono/codingpractice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReverseArray.cpp
More file actions
50 lines (39 loc) · 760 Bytes
/
ReverseArray.cpp
File metadata and controls
50 lines (39 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
WAP to reverse elements of an array...
*/
#include<iostream>
#include<cstdlib>
#include<dos>
using namespace std;
int main()
{
void condition(int);
void reverse(int [],int);
int arr[100],size;
cout<<"Enter size of array <99 :";
cin>>size;
condition(size); //to check if entered size is in given range or not
cout<<"\nEnter array elements:\n";
for(int i=0;i<size;i++)
cin>>arr[i];
reverse(arr,size); //function call
return 0;;
}
void condition(int size)
{
if(size<=0||size>99)
{
cout<<"Enter in given range only!!!";
sleep(1);
exit(0);
}
}
void reverse(int arr[],int size)
{
int swap[100],t;
for(int i=0,j=size-1;i<size,j>=0;i++,j--)
swap[j]=arr[i];
cout<<"\nReversed array is:\n";
for(i=0;i<size;i++)
cout<<swap[i]<<"\t";
}