You are Here: Home > Computer Subjects > Unix Shell Programming…
Match String by taking User Input
Code:
clear echo -n "Enter the Number==> " read n i=1 if test $n -ge 0 then if test $n -eq 0 then echo "You have to enter a number greater than zero." else while test $i -le $n do v=`expr $i \* $i` echo "Square of "$i "is = "$v i=`expr $i + 1` done fi else echo "Program can't accept negative value." fi
Output:
Enter the Number==> 6
Square of 6 is = 36
Click Here to Find Latest Jobs and Current Affairs