How can I remove the following error?

How can I remove the following error?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  #include <iostream>

using namespace std;
int reverse(int n)
{
    int x, y, i, k;
    while(x)
    {
        if(n>0||n<0)
        {
          x=n%10;n=n/10;
          y=i*10+x;
          i++;
        }
    }
    return y;
}
int main()
{
    int n;
    cin>>n;
    cout<< reverse();
    return 0;
}


Error:
1
2
3
4
5
6
main.cpp:30:20: error: too few arguments to function ‘int reverse(int)’
   30 |     cout<< reverse();
      |                    ^
main.cpp:12:5: note: declared here
   12 | int reverse(int n)
      |     ^~~~~~~
reverse(n) ?

The function expects to be given an integer, give it one.
Surely L9 is just

 
if (n)

1
2
    int x, y, i, k;
    while(x)

What's x?



Come to think of it,
1
2
3
    int x, y, i, k;
...
          y=i*10+x;

What's i? And why do you need k?
Last edited on
Thanks To all of you
Topic archived. No new replies allowed.