Reputation: 27
int hour = 10;
if (hour > 0 && < 12)
Console.WriteLine("It's morning.");
else if (hour >= 12 && < 18)
Console.WriteLine("It's afternoon.");
else
Console.WriteLine("It's evening.");
Keep receiving an error
Invalid Expression Term '<'
Preliminary search on the issue did not yield results. Hoping to learn why this piece of code is experiencing this issue and how I can avoid it in the future.
Upvotes: 1
Views: 472
Reputation: 2703
You're missing the parameter in the second part of your conditions.
int hour = 10;
if (hour > 0 && hour < 12)
Console.WriteLine("It's morning.");
else if (hour >= 12 && hour < 18)
Console.WriteLine("It's afternoon.");
else
Console.WriteLine("It's evening.");
Upvotes: 2