Saturday, May 30, 2020

If statement compound condition matching

#!/bin/ksh
#prompt the user to enter a number
print -n "Enter your age: "
read age
print
print -n "enter the number of children you have :"
read numberofchildren
if ( (( age < 30 )) && (( numberofchildren==0 )) ); then #the space after the ( and before the ) is important

print "Single and loving it"
fi
if (  ((age > 30)) || ((numberofchildren!=0)) ); then
print "things could be worse"
fi
#operators are &&,||

No comments:

Post a Comment