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

  1. echo "Enter marks(out of 30) of "
  2. read -p "Subject 1: " s1
  3. read -p "Subject 2: " s2
  4. read -p "Subject 3: " s3
  5. sum=`expr $s1 + $s2 + $s3`
  6. echo "Sum of marks of 3 subjects is : "$sum
  7. per=`expr $sum \* 10 / 9`
  8. echo "Percentage: "$per
  9. if [ $per -ge 60 ]
  10. then
  11. echo "you got Distinction"
  12. elif [ $per -ge 50 ]
  13. then
  14. echo "you got First class"
  15. elif [ $per -ge 40 ]
  16. then
  17. echo "You got second class"
  18. else
  19. echo "sorry you failed! better luck next time"
  20. 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 OS Program - 11 Filters

GTU OS Program - 13 Date Validator

GTU OS Program - 8