echo "Enter marks in subject1"
read m1
echo "Enter marks in subject2"
read m2
echo "Enter marks in subject3"
read m3
sum=`expr $m1 + $m2 + $m3`
echo "Sum is = " $sum
percentage=`expr $sum / 3`
if test $percentage -ge 70
then
echo "You have got a distinction!"
elif test $percentage -ge 60
then
echo "You have got a first class!"
elif test $percentage -ge 40
then
echo "You are qualified!"
else
echo "You have failed!"
fi
program to implement if then else
Out put:
[csuser@localhost ~]$ vi ra
[csuser@localhost ~]$ chmod 777 ra (ra is file name)
[csuser@localhost ~]$ ./ra
Enter marks in subject1
23
Enter marks in subject2
34
Enter marks in subject3
45
Sum is = 102
You have failed!
read m1
echo "Enter marks in subject2"
read m2
echo "Enter marks in subject3"
read m3
sum=`expr $m1 + $m2 + $m3`
echo "Sum is = " $sum
percentage=`expr $sum / 3`
if test $percentage -ge 70
then
echo "You have got a distinction!"
elif test $percentage -ge 60
then
echo "You have got a first class!"
elif test $percentage -ge 40
then
echo "You are qualified!"
else
echo "You have failed!"
fi
program to implement if then else
Out put:
[csuser@localhost ~]$ vi ra
[csuser@localhost ~]$ chmod 777 ra (ra is file name)
[csuser@localhost ~]$ ./ra
Enter marks in subject1
23
Enter marks in subject2
34
Enter marks in subject3
45
Sum is = 102
You have failed!
No comments:
Post a Comment