Exercise: Functions
Questions for: Functions
What will be the output of the following program?
#include<iostream.h>
struct MyData
{
public:
int Addition(int a, int b = 10)
{
return (a *= b + 2);
}
float Addition(int a, float b);
};
int main()
{
MyData data;
cout<<data.Addition(1)<<" ";
cout<<data.Addition(3, 4);
return 0;
}
A:
12 12
B:
12 18
C:
3 14
D:
18 12
Answer: B
No answer description is available. Let's discuss.
Which of the following statement is correct about the program given below?
#include<iostream.h>
long GetNumber(long int Number)
{
return --Number;
}
float GetNumber(int Number)
{
return ++Number;
}
int main()
{
int x = 20;
int y = 30;
cout<< GetNumber(x) << " ";
cout<< GetNumber(y) ;
return 0;
}
A:
The program will print the output 19 31.
B:
The program will print the output 20 30.
C:
The program will print the output 21 31.
D:
The program will print the output 21 29.
Answer: C
No answer description is available. Let's discuss.
Discuss About this Question.
Which of the following statement is correct about the program given below?
#include<iostream.h>
class ExamAdept
{
public:
void Bix(int x = 15)
{
x = x/2;
if(x > 0)
Bix();
else
cout<< x % 2;
}
};
int main()
{
ExamAdept objIB;
objIB.Bix();
return 0;
}
A:
The program will display 1.
B:
The program will display 2.
C:
The program will display 15.
D:
The program will go into an infinite loop.
Answer: D
No answer description is available. Let's discuss.
Discuss About this Question.
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;
}
A:
10
B:
20
C:
30
D:
40
Answer: C
No answer description is available. Let's discuss.
Discuss About this Question.
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;
}
A:
The program will print the output 10 20.
B:
The program will print the output 10 0.
C:
The program will print the output 10 garbage.
D:
The program will report compile time error.
Answer: A
No answer description is available. Let's discuss.
Discuss About this Question.
Ad Slot (Above Pagination)
Discuss About this Question.