ans: echo "Enter 1st number:" read num1 echo "Enter 2nd number:" read num2 res=`expr $num1 + $num2` echo "The Sum is $res"
ans: echo "Enter 1st Number:" read num1 echo "Enter 2nd Number:" read num2 echo "Entr 3rd Number:" read num3 res=`expr $num1 + $num2 + $num3` echo "The Sum Is $res"
ans: echo "enter 1st Number:" read num1 echo "enter 2nd Number:" read num2 if test $num1 -gt $num2 then echo "$num1 is greatest" else echo "$num2 is greatest" fi
ans: echo "Enter 1st Number:" read num1 echo "Enter 2nd Number:" read num2 echo "Enter 3rd Number:" read num3 if test $num1 -gt $num2 -a $num1 -gt $num3 then echo "$num1 is greatest" elif test $num2 -gt $num3 then echo "$num2 is greatest" else echo "$num3 is greatest" fi
ans: num=1 while test $num -le 10 do echo $num num=`expr $num + 1` done
ans: num=20 while test $num -ge 1 do echo $num num=`expr $num - 1` done
ans: a=0 b=1 i=1 echo "$a" echo "$b" while test $i -le 18 do c=`expr $a + $b` echo "$c" a=$b b=$c i=`expr $i + 1` done
ans: i=2 flag=0 echo "enter a number" read num while test $i -lt $num do rem=`expr $num % $i` if test $rem -eq 0 then flag=1 break fi i=`expr $i + 1` done if test $flag -eq 0 then echo "The Number Is Prime" else echo "The Number is Not Prime" fi
ans: n=2 while test $n -le 100 do flag=0 i=2 while test $i -lt $n do rem=`expr $n % $i` if test $rem -eq 0 then flag=1 break fi i=`expr $i + 1` done if test $flag -eq 0 then echo "$n" fi n=`expr $n + 1` done
ans: count=0 n=2 while test $count -lt 100 do flag=0 i=2 while test $i -lt $n do rem=`expr $n % $i` if test $rem -eq 0 then flag=1 break fi i=`expr $i + 1` done if test $flag -eq 0 then count=`expr $count + 1` echo "$count. $n" fi n=`expr $n + 1` done
ans: rev=0 echo "enter a number" read num while test $num -gt 0 do r=`expr $num % 10` rev=`expr $rev \* 10` rev=`expr $rev + $r` num=`expr $num / 10` done echo "$rev"
ans: count=1 num=1 while test $count -le 500 do n=$num rev=0 while test $n -ne 0 do r=`expr $n % 10` rev=`expr $rev \* 10` rev=`expr $rev + $r` n=`expr $n / 10` done if test $num -eq $rev then echo "$count) $num" count=`expr $count + 1` fi num=`expr $num + 1` done
ans: echo "Enter a Number:" read n b="" while test $n -gt 0 do tmp=`expr $n % 2` b=$tmp$b n=`expr $n / 2` done echo $b
ans: num=0 while test $num -gt 500 do echo "$num" n=$num b="" while test $n -gt 0 do temp=`expr $n + 2` b=$temp$b n=`expr $n / 2` done echo "$num) $b" done
ans: echo "enter a number" read n num=$n; o="" while test $num -gt 0 do temp=`expr $num % 8` o=$temp$o num=`expr $num / 8` done echo $o num=$n; h="" while test $num -gt 0 do temp=`expr $num % 16` h=$temp$h num=`expr $num / 16` done echo $h
ans: num=0 while test $num -le 500 do n=$num b="" while test $n -gt 0 do temp=`expr $n % 2` b=$temp$b n=`expr $n / 2` done n=$num o="" while test $n -gt 0 do temp=`expr $n % 8` o=$temp$o n=`expr $n / 8` done n=$num h="" while test $n -gt 0 do temp=`expr $n % 16` if test $temp -eq 10 then h="A"$h elif test $temp -eq 11 then h="B"$h elif test $temp -eq 12 then h="C"$h elif test $temp -eq 13 then h="D"$h elif test $temp -eq 14 then h="E"$h elif test $temp -eq 15 then h="F"$h else h=$temp$h fi n=`expr $n / 16` done echo "$num , $b , $o , $h" num=`expr $num + 1` done
ans: clear for i in 1 2 3 4 5 6 7 8 9 10 do echo $i done
ans: clear for i in 'ls - l' do echo $i done
ans: num=1 untill test $num -gt 10 do echo $num num='expr $num + 1' done
clear for i in `ls` do if test -d $i then echo "$i is directory" elif test -f $i then echo "$i is file" else echo "$i is not a file or directory" fi done