C++ Programming - References - Discussion
Discussion Forum : References - Programs (Q.No. 5)
5.
Which of the following statement is correct about the program given below?
#include<iostream.h>
enum bix
{
a=1, b, c
};
int main()
{
int x = c;
int &y = x;
int &z = x;
y = b;
cout<< z--;
return 0;
}
Discussion:
15 comments Page 2 of 2.
Zubair Bhatti said:
1 decade ago
Why we use enum?
D.s.raghuram said:
1 decade ago
In enum here a=1,hence then b will be 2 and c will be 3.
x=3.
y=3.
z=3.
y=2 i.e.
x=2 i.e.
z=2.
And decrement operator will effect only after the output !
Thus output = 2.
x=3.
y=3.
z=3.
y=2 i.e.
x=2 i.e.
z=2.
And decrement operator will effect only after the output !
Thus output = 2.
Honey Garg said:
1 decade ago
Because here we used enum. In enum when we initialized variable the value will be in incremented order.
Anonymous said:
1 decade ago
Why the value of x, y, z is 3?
Prerak said:
1 decade ago
x=3
y=3
z=3
y=2 i.e.
x=2 i.e.
z=2
And decrement operator will effect only after the output !
Thus output = 2.
But z = 1.
y=3
z=3
y=2 i.e.
x=2 i.e.
z=2
And decrement operator will effect only after the output !
Thus output = 2.
But z = 1.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers