GTU OS Program - 6

6. Write a shell script which will generates first n fibonacci numbers like: 1, 1, 2, 3, 5, 13,…

Complete code of the program

  1. read -p "Enter the value of n (number): " n
  2. x=0
  3. y=1
  4. i=2
  5. echo "Fibonacci Series up to $n terms is : "
  6. echo "$x"
  7. echo "$y"
  8. while [ $i -lt $n ]
  9. do
  10. i=`expr $i + 1`
  11. z=`expr $x + $y`
  12. echo "$z"
  13. x=$y
  14. y=$z
  15. done

Interpreting the fibonacci.sh file and executing it in terminal

  1. tkanu025@hp:~/lab_solutions$ chmod +x fibonacci.sh
  2. tkanu025@hp:~/lab_solutions$ ./fibonacci.sh
Output



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 - 8

GTU OS Program - 13 Date Validator