0

Reverse , plz help me find my mistake and correct it

https://code.sololearn.com/c5jea47TP04n/?ref=app

9th Dec 2021, 5:36 AM
PRIYANSHU GOYAL
PRIYANSHU GOYAL - avatar
2 Respostas
+ 1
you calling function in wrong way first you have to write function name then round brackets with semicolon u can't use equal operator #include <iostream> using namespace std; void reverse(int arr[] , int n){ int s = 0; int e =n-1; while (s<=e){ swap(arr[s] , arr[e]); s++; e--; } } void printArray(int arr[] , int n){ for (int i =0; i<n; i++){ cout<< arr[i]<<" "; } cout<<endl; } int main() { int arr[6] = {1,2,3,4,5,6}; reverse(arr,6); printArray(arr,6); return 0; }
9th Dec 2021, 5:44 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
In main function your declarations of void functions are wrong. You declare them as functions who have to return something. So delete '=' signs and they will work fine.
11th Dec 2021, 4:02 AM
TeaserCode