1.Which is not a proper function prototype? void doThis (string x); 2.If a funct
ID: 3588943 • Letter: 1
Question
1.Which is not a proper function prototype?
void doThis (string x);
2.If a function has six parameters defined, how many arguments must appear in the function call?
3.
What is wrong with the following function definition?
void square (int x)
{
return x * x;
}
nothing
4.
Once declared, a local variable
is another name for argument
5.
What is wrong with the following code?
int doSomething (int x)
{
return x;
}
int doSeomthingElse (int x)
{
string s;
int y = doSomething(s);
}
nothing
6.
In the code below, changing the value of x in doSomething will also change the value of x in main.
int main ()
{
int x;
doSomething(x);
}
void doSomething (int x)
{
x = x + 1;
}
double doThis ();Explanation / Answer
1. void (string doThis); (c) - This function doesn't have name
2. When there are 6 parameters in the function, all the 6 must appear as arguments
3. Return type of the function is void, but we are returnign integer. (b)
4. scope of local variable is limited to block where it is defined (b)
5. doSomething function requires an int parameter, but we are invoking with string parameter (c)
6. no, it is false. We are passing argument by value. In this case, the original variable won't be changed.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.