The code defines an enumeration type named week, which has seven constants corresponding to the days of the week. The main() function creates an instance of the week enumeration named today and initializes it to the constant Wednesday. The cout statement then prints the day of the week represented by today incremented by 1.
Since the first constant Sunday has the value 0, and the subsequent constants have incrementing values by 1, adding 1 to today will give us the value of the next day of the week. In this case, since today is initialized to Wednesday, adding 1 to it will give us the value 4 (corresponding to Thursday).
#include<iostream> using namespace std; enum week { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday }; int main() { week today; today=Wednesday; cout<<"Day "<<today+1; return 0; }To download raw file Click Here
Day 4
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions