New Trending Topics and Study Material

Breaking

Tag

Tricks & Tips (17) News (5) PHP (5) Android (3) SEO (1) free paytm cash (1)

Tuesday, 31 January 2017

Practical Problems


Practical Problems


A  Bash Shell Scripting



 Write a script that check the number is palindrome or not.



#!/bin/bash

#Tuesday 31 January 2017 11:36:55 AM IST 

#VR Tech Tips

#Write a script that check the number is palindrome or not.

echo "Enter Number : "

read a

tmp=$a

r=0

while [ $tmp -ne 0 ]

do

r=`expr $r \* 10 + $tmp % 10 `

tmp=`expr $tmp / 10 `


done

if [ $r -eq $a ]

then

echo "Number is Palindrome"

else

echo "Number is Not Palindrome"

fi






 Write a script to perform all Arithmetic     operations on floating point values.
     


#!/bin/bash
#Tuesday 31 January 2017 11:43:26 AM IST  
#VR Tech Tips
#Write a script to perform all Arithmetic operations on floating point values. 
echo "Enter Value 1 : "
read a
echo "Enter Value 2 : "
read b
c=`expr "($a + $b)" | bc `
d=`expr "($a * $b)" | bc `
e=`expr "($a / $b)" | bc `
f=`expr "($a - $b)" | bc `
v=0
while [ $v -ne 5 ]
do
echo "1.Addition "
echo "2.Multiplication "
echo "3.Division "
echo "4.Subtraction "
echo "5.Exit"
read v
case $v in
1) echo  "Addition : $c"
;;
2) echo  "Multiplication : $d"
;;
3) echo  "Division : $e"
;;
4) echo  "Exit : $f"
;;
esac
done






 Write a script to print multiplication table of any number using FOR loop. 


#!/bin/bash
#Tuesday 31 January 2017 12:13:05 PM IST   
#VR Tech Tips
#Write a script to perform all Arithmetic operations on floating point values. 
echo "Enter Number"
read v
a=0
for i in 1 2 3 4 5 6 7 8 9 10
do 
a=`expr "($v * $i)" | bc`
echo "$v * $i   = $a"
done






Write a script to find Factorial of given number. 

#!/bin/bash
#Tuesday 31 January 2017 12:26:01 PM IST  
#VR Tech Tips
#Write a script to find Factorial of given number.\
echo -n "Enter Number : "
read v
b=$v
a=1
while [ $v -ne 1 ]
do
a=`expr $a \* $b`
b=`expr $b - 1 `
v=`expr $v - 1 `
done
echo ":::::::::::::::::::::::::::"
echo ":        $a   :"
echo ":::::::::::::::::::::::::::"






 Write a script to count number of odd and even digits within given number.;

#!/bin/bash
#Tuesday 31 January 2017 12:59:41 PM IST   
#VR Tech Tips
#Write a script to count number of odd and even digits within given number.
echo "Enter Number : "
read a
tmp=$a
r=0
while [ $tmp -ne 0 ]
do
r=`expr $r \* 10 + $tmp % 10 `
tmp=`expr $tmp / 10 `
if [ $r -eq 0 ]
then
    echo "Number is Zero" 
    elif [ `expr $r % 2 ` -eq 0   ]
      then
v=`expr $v + 1`
      else
s=`expr $s + 1`
fi
done
echo "Toatal Even Number is :-> $v"

echo "Total ODD Number is :-> $s"






 Write script to print given numbers sum of all digit, For eg. If no is 123 it's sum of all digit will be 1+2+3 = 6. 

#!/bin/bash
#Tuesday 31 January 2017 01:09:42 PM IST   
#VR Tech Tips
#Write script to print given numbers sum of all digit, For eg. If no is 123 it's
sum of all digit will be 1+2+3 = 6.
echo "Enter Number : "
read a
tmp=$a
r=1
v=0
while [ $tmp -ne 0 ]
do
r=`expr  $tmp % 10 `
tmp=`expr $tmp / 10 `
v=`expr $r + $v `
done
echo "Toatal Even Number is :-> $v"


  Please Support My Blog and Share  It with Your Friends & Groups


No comments:

Post a Comment