Click here to Skip to main content
15,507,526 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Write a program for allowing people below 70 and above 18 to drive else not?

What I have tried:

<pre>if (age >= 18 && age <= 70){
        printf("You are below 70 and above 18, you can drive\n");
    }
    else{
        printf("You cannot drive\n");
    }




if (age <= 18 && age >= 70){
        printf("You are above 70 and below 18, you cannot drive\n");
    }
    else{
        printf("You can drive\n");
    }
Posted
Updated 26-Aug-21 10:13am

1 solution

Think about what you wrote: is it possible to be both under 18 and over 70 at the same time?

Or should that be "under 18 or over 70"?
 
Share this answer
 
Comments
Abhishek Raj 2021 26-Aug-21 15:52pm    
Oh! my bad. Got it. Thank you so much OriginalGriff. Keep inspiring.
OriginalGriff 26-Aug-21 15:54pm    
You're welcome!
CPallini 27-Aug-21 2:23am    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900