Oct 22, 2008 at 4:11pm UTC
1)write a c++ statements that do the following:
a) define an enum type, bookType, with the values MATH,CSC,ENGLISH,HISTORY,PHYSICS, and PHILOSOPHY.
b) declare a variable book of type bookType.
c) Assign MATH to the variable book.
d) Advance book to the next value in the list
e) Output the value of the variable book.
2)Given:
enum cropType {WHEAT,CORN,RYE,BARLEY,OATS}
cropType crop;
circle the correct answer.
a)static_cast<int>(WHEAT) is 0
(i)true (ii)false
b)static_cast<cropType>(static_cast<int>(WHEAT)-1)is
WHEAT
(i)true (ii)false
c)Rye>WHEAT
(i)true (ii)false
d) for (crop=wheat; crop<=oats; ++crop)
cout<<"*";
cout<<endl;
outputs: *****
(i)true (ii)false
Last edited on Oct 22, 2008 at 4:11pm UTC
Oct 22, 2008 at 4:48pm UTC
If you read exercise 2 you will get answers to questions 1.a and 1.b except for a missing semicolon.
I think that you should first try your exercises and then ask us for help if something went wrong
Oct 22, 2008 at 5:25pm UTC
Thanks I already got ex1, , but I am having trouble with 2
Oct 22, 2008 at 5:28pm UTC
Hint:
cout << static_cast <int >(WHEAT);
will help you solving 2.a
If you do something like that for all the questions you will solve the exercise