C++ Programming - Objects and Classes - Discussion
Discussion Forum : Objects and Classes - Programs (Q.No. 6)
6.
What will be the output of the following program?
#include<iostream.h>
class India
{
public:
struct Bix
{
int x;
float y;
void Function(void)
{
y = x = (x = 4*4);
y = --y * y;
}
void Display()
{
cout<< y << endl;
}
}B;
}I;
int main()
{
I.B.Display();
return 0;
}
Discussion:
25 comments Page 1 of 3.
Paanku said:
7 years ago
It is because we have a global object.
For global objects, all members are initialised to zero.
For global objects, all members are initialised to zero.
(1)
Neha said:
7 years ago
Because y is global variable for function display and global variable value by default is zero.
(1)
Tanmay said:
8 years ago
The void Function (void) will not be called simply.
If we have written I.B.Function then things would have been different.
If we have written I.B.Function then things would have been different.
Swetha said:
8 years ago
Hello.
I'd like to assert that the main function is returning a 0,
hence, 0!.
I'd like to assert that the main function is returning a 0,
hence, 0!.
Faree said:
9 years ago
Functions can't be defined inside a structure, so how the answer is 0?
Nikhil said:
9 years ago
How the output will be zero?
Not understand please explain it.
Not understand please explain it.
Scorpionsrk7 said:
9 years ago
What is the B and L in this program?
Nuzhat said:
10 years ago
y = x = (x = 4*4).
Explain above in details.
x = 4*4 = 16?
How could it 1?
Explain above in details.
x = 4*4 = 16?
How could it 1?
Nishant sharma said:
10 years ago
Since argument type of function is void therefore it takes no arguments. Hence answer is zero.
Priya said:
1 decade ago
Why answer is zero? How the function is evaluated?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers