GTU OS Program - 3

3. Write a shell script to generate marksheet of a student. Take 3 subjects, calculate and display total marks, percentage and Class obtained by the student.

Make a file called marksheet.sh using vim. If you want a full guide to vim than you can check this post.

tkanu025@hp:~/lab_solutions$ vim marksheet.sh 

When you will hit enter than it will open a window like the one below. This is an editor and Here you can write your code. Press i to enter into the insert mode

Gujarat Technological university OS programs cse gtu

Write full code there like this

echo "Enter marks(out of 30) of "
read -p "Subject 1: " s1
read -p "Subject 2: " s2
read -p "Subject 3: " s3
sum=`expr $s1 + $s2 + $s3`
echo "Sum of marks of 3 subjects is : "$sum
per=`expr $sum \* 10 / 9`
echo "Percentage: "$per
if [ $per -ge 60 ]
then
        echo "you got Distinction"
elif [ $per -ge 50 ]
then
        echo "you got First class"
elif [ $per -ge 40 ]
then
        echo "You got second class"
else
        echo "sorry you failed! better luck next time"
fi

Then press ESC and then Enter :wq which will bring you out of the vim editor writing that code into your marksheet.sh file.

cse gtu

Now compile and run the created file.

tkanu025@hp:~/lab_solutions$ chmod +x marksheet.sh
tkanu025@hp:~/lab_solutions$ ./marksheet.sh 

Here is the Output of this program

Gujarat technological university

gtu os lab manual,

os GTU Practical,

operating system Programs,

Operating system shellscript programs,

Gtu study material 3140705,

OS 3140702,

os practical list,

shell script programming,

gtu os practical,

os lab solution gtu

Comments

YouTube

Popular posts from this blog

GTU OOP Programs - 11

Mini project ideas for Operating System

GTU OS Program - 8