Skip to content

Commit dab6f2c

Browse files
committed
Create evenOddCheck.cpp
1 parent 27abb0c commit dab6f2c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

evenOddCheck.cpp

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
int main()
6+
{
7+
int n;
8+
string result[2] = {"Even", "Odd"};
9+
cin >> n;
10+
cout << result[n % 2];
11+
}
12+
13+
/* An alternative approach by Lokeshwaran of CSE A, II year is given below
14+
#include <iostream>
15+
16+
using namespace std;
17+
18+
int main()
19+
{
20+
int n = 3;
21+
while(n%2){
22+
cout<<"Odd";
23+
return 0;
24+
}
25+
cout<<"Even";
26+
}
27+
28+
*/
29+

0 commit comments

Comments
 (0)