-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpracticep7.cpp
More file actions
43 lines (38 loc) · 788 Bytes
/
practicep7.cpp
File metadata and controls
43 lines (38 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>
using namespace std;
//enumeration
enum seasons{
spring=2, summer, autumn, winter=89 //default value of spring is 0. But we can change it. Then all the
//other values are like 2+1,3+1...
};
//Directly Using Enum Values in Code
int function1(){
seasons s;
s=autumn;
//s=rainy; error as seasons does not have rainy as a value;
cout<<s<<endl;
}
//Directly Using Enum Values in Code
int function2(){
int s;
cin >> s;
if(s==spring){
cout<<"Spring";
}
else if (s==summer){
cout<<"Summer";
}
else if (s==autumn){
cout<<"Autumn";
}
else if (s==winter){
cout<<"Winter";
}
else{
cout<<"Invalid season";
};
};
int main(){
function1();
function2();
};