How to return all the Elements of an array.
Hey Guys! I'm just a newbie here, I need help with my code;
How do I return the values in the element? can it be done?
or should I just rewrite my code?. I'll be pleased if you help me thank you.
#include <iostream>
using namespace std;
int swap(int s[4]);
int main(){
int num[5] = {1, 4, 9, 16, 25};
//for(int i = 0; i < 5; i++)
//{
// cout << num[i] << ' ';
//}
cout << endl;
cout << swap(num);
cout << endl;
system("Pause");
return 0;
}
int swap(int s[4])
{
int temp;
int a,b;
a = s[0];//1
b = s[4];//25
temp = a;
a = b;
b = temp;
int final[5] = {a , s[1] , s[2] , s[3] , b};
}
return final[5];
}
the problem lies on the function
Thank you very much, you made it simple enough