Write a function isOldEnough that takes an input called num as an argument. The function should return either true or false based on the following logic:
- It returns true if the number is greater than or equal to 18
- It returns false if the number is non-negative but less than 18
- It returns "Invalid argument" if the number is negative or if it's not a number at all
This is just a bunch of if
s. I'm sure you can do it.
@a5rocks I am very new to this i am trying my best however there is something just wrong
@ayaanHasan Can you send the code?
@ayaanHasan what language are you making this for? I recommend googling / whatever-search-engine-you-use-ing for a tutorial on:
- functions
- if statements
- how to get a variable's class
What have you done so far? What seems to be the problem? What language are you working in?
Have a look at https://www.tutorialspoint.com/cplusplus/cpp_if_else_statement.htm for an overview of if-else statements and then come back with more questions.
Yip
Try using if
, and
, else
, elif
!
please upvote or mark as answer if helpful
@ayaanHasan I quickly wrote this, let me know if it solved your problem!
@EchoCoding thank you for your help. However the code you sent is not working for some reason.
@ayaanh22 How is it not working? It prints True of False depending on the scenario.