We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Day 3: Intro to Conditional Statements
Day 3: Intro to Conditional Statements
Sort by
recency
|
1811 Discussions
|
Please Login in order to post a comment
C++
Java solution if(N % 2 ==0){ if( N < 5 || N > 20){ System.out.println("Not Weird"); }else{ System.out.println("Weird"); } }else{ System.out.println("Weird"); }
** Here is the solution in 2 if statements **
if ( (N % 2) != 0 || (N %2 ==0 && (N >=6 && N<= 20)) ) cout << "Weird" << endl; else if (N %2 ==0 && ((N >=2 && N<= 5)||( N >=20))) cout << "Not Weird" << endl;