Exercise: Python

Questions for: Functions

What will be the output of the following program?
#include<iostream.h> 
void MyFunction(int a, int b = 40)
{
    cout<< " a = "<< a << " b = " << b << endl;
}
int main()
{
    MyFunction(20, 30);
    return 0; 
}
A:
a = 20 b = 40
B:
a = 20 b = 30
C:
a = 20 b = Garbage
D:
a = Garbage b = 40
Answer: B
No answer description is available. Let's discuss.
What will be the output of the following program?
#include<iostream.h>
int BixFunction(int a, int b = 3, int c = 3)
{
    cout<< ++a * ++b * --c ; 
    return 0;
}
int main()
{
    BixFunction(5, 0, 0); 
    return 0;
}
A:
8
B:
6
C:
-6
D:
-8
Answer: C
No answer description is available. Let's discuss.
What will be the output of the following program?
#include<iostream.h>
long BixFunction(int x, int y = 5, float z = 5)
{
    return(++x * ++y + (int)++z);
}
int main()
{
    cout<< BixFunction(20, 10); 
    return 0;
}
A:
237
B:
242
C:
240
D:
35
Answer: A
No answer description is available. Let's discuss.
Which of the following function / types of function cannot have default parameters?
A:
Member function of class
B:
main()
C:
Member function of structure
D:
Both B and C
Answer: B
No answer description is available. Let's discuss.
Where the default value of parameter have to be specified?
A:
Function call
B:
Function definition
C:
Function prototype
D:
Both B or C
Answer: C
No answer description is available. Let's discuss.
Ad Slot (Above Pagination)
Quiz