0

I think enum counting in a same sequence of range but this code l don't understand enum concept . What is the output? Explain

Enum{ Orange= 5, Banana=4, Peach }; Printf("%d",peach);

23rd Aug 2020, 5:47 AM
Suparna Podder
Suparna Podder - avatar
8 ответов
+ 6
After swim explanation you have doubts means you didn't read basics .  If we do not explicitly assign values to enum names, the compiler by default assigns values starting from 0. For example, Enum { Monday , Tuesday, Thursday, Friday} If u will print Monday it will print 0 becoz if u wont set any value it will start from 0 ig u will print Friday it will print 3 Same in your Question u set initial value 5 in orange Banana is 4 but u not define value of peach so it will 5 automatically becoz before value banana is 4 If u will add more key(fruits ) after peach like Cherry it will come after peach so Cherry will be 6. May be u will understood clearly
23rd Aug 2020, 6:15 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 4
Suparna Podder Sir actully you posting all Challenges Question here don't post all Question here first read basics of languages then try to solve by self if you have doubts then you can post . You posting question back to back and i think question are easy if u know basics u can find answer self . For small Question you can post in Activity feeds . ........Thankyou.......
23rd Aug 2020, 6:07 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 1
Ada lovelace Actually challanging questions don't understand how to slove . When l slove this but after a time l see this answer is not matching my solved answer . That's why l ask some questions here! Someone from this community answer my questions then my doubt is clear. I think u understand my problem. If u want to give any suggestion,. U should tell me.
23rd Aug 2020, 6:14 AM
Suparna Podder
Suparna Podder - avatar
+ 1
Thanks a lot ~ swim ~
23rd Aug 2020, 6:45 AM
Suparna Podder
Suparna Podder - avatar
+ 1
Ada lovelace l think that l 'm not telling any laughing things.
23rd Aug 2020, 6:48 AM
Suparna Podder
Suparna Podder - avatar
0
~ swim ~ Allready orange value 5 is defined so, how peach value 5
23rd Aug 2020, 5:59 AM
Suparna Podder
Suparna Podder - avatar
0
Ok got it
23rd Aug 2020, 6:02 AM
Suparna Podder
Suparna Podder - avatar
0
Ada lovelace thanks a lot. U give to suggest any best cpp tutorial link ?
23rd Aug 2020, 6:19 AM
Suparna Podder
Suparna Podder - avatar