C++ Programming - References - Discussion
Discussion Forum : References - Programs (Q.No. 11)
11.
Which of the following statement is correct about the program given below?
#include<iostream.h>
enum xyz
{
a, b, c
};
int main()
{
int x = a, y = b, z = c;
int &p = x, &q = y, &r = z;
p = ++x;
q = ++y;
r = ++c;
cout<< p << q << r;
return 0;
}
Discussion:
5 comments Page 1 of 1.
Deepthi mayi said:
8 years ago
Attempt to change the values of enum variables may result in compile time error.
(2)
Shyam said:
1 decade ago
Enum variables cannot be changed once they are defined at r=++c it results a error.
Atul Kumar said:
1 decade ago
Because the value of the enum variables will be as
a=0 b=1 c=2.
But as given r=++c means c=3 but c=3 can't be possible Because last value is 2.
a=0 b=1 c=2.
But as given r=++c means c=3 but c=3 can't be possible Because last value is 2.
Lavanyeswari motupalli said:
1 decade ago
enum is a user defined keyword which is used to hold set of constants so the variables in enum (a,b,c) can't be altered i.e r=++c (give error).
Vamshi said:
7 years ago
#include<iostream.h> is unvalid header in both c and c++.
And in r=++c instruction c is an enum. We can't increase enum values.
And in r=++c instruction c is an enum. We can't increase enum values.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers