DEV Community

Ogunniyi Owamamwen
Ogunniyi Owamamwen

Posted on

C# - Day 3: Conditional-Statements - 30 Days of Code HackerRank

Task
Given an integer, , perform the following conditional actions:

  1. If is odd, print Weird
  2. If is even and in the inclusive range of to , print Not Weird
  3. If is even and in the inclusive range of to , print Weird
  4. If is even and greater than , print Not Weird
  5. Complete the stub code provided in your editor to print whether or not is weird.

using System;

class Solution
{
public static void Main(string[] args)
{
int N = Convert.ToInt32(Console.ReadLine().Trim());
if(N%2==0)
{
if(N>=2 && N<=5){
Console.WriteLine("Not Weird");
}
else if(N>=6 && N<=20){
Console.WriteLine("Weird");
}else{
Console.WriteLine("Not Weird");
}
} else{
Console.WriteLine("Weird");
}
}
}

Top comments (0)