0
Reverse , plz help me find my mistake and correct it
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;
}
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.