C++ Programming - Functions

Exercise : Functions - Programs
1.
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;
}
237
242
240
35
The program will report error on compilation.
Answer: Option
Explanation:
No answer description is available. Let's discuss.

2.
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;
}
8
6
-6
-8
Answer: Option
Explanation:
No answer description is available. Let's discuss.

3.
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 = 20 b = 40
a = 20 b = 30
a = 20 b = Garbage
a = Garbage b = 40
Answer: Option
Explanation:
No answer description is available. Let's discuss.

4.
Which of the following statement is correct about the program given below?
#include<iostream.h> 
static int b = 0; 
void DisplayData(int *x, int *y = &b)
{
    cout<< *x << " " << *y;
}
int main()
{
    int a = 10, b = 20 ;
    DisplayData(&a, &b);
    return 0; 
}
The program will print the output 10 20.
The program will print the output 10 0.
The program will print the output 10 garbage.
The program will report compile time error.
Answer: Option
Explanation:
No answer description is available. Let's discuss.

5.
What will be the output of the following program?
#include<iostream.h> 
typedef void(*FunPtr)(int);
int Look(int = 10, int = 20);
void Note(int); 
int main()
{
    FunPtr ptr = Note;
    (*ptr)(30); 
    return 0;
}
int Look(int x, int y)
{
    return(x + y % 20);
}
void Note(int x)
{
    cout<< Look(x) << endl;
}
10
20
30
40
Compilation fails.
Answer: Option
Explanation:
No answer description is available. Let's discuss.