gra*_*ndx 8 c++ integer function
我试图创建一个函数,返回我将传递给它的整数的两倍.我的代码收到以下错误消息:
'int x'的声明会影响参数int x; "
这是我的代码:
#include <iostream>
int doublenumber();
using namespace std;
int doublenumber(int x)// <-- this is the function which returns double the value .
{
int x;
return 2 * x;
cout << endl;
}
int main()
{
int a;
cout << "Enter the number that you want to double it : " << endl;
cin >> a;
doublenumber(a);
return 0;
}
Run Code Online (Sandbox Code Playgroud)