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

read -p "Enter the value of n (number): " n
x=0
y=1
i=2
echo "Fibonacci Series up to $n terms is : "
echo "$x"
echo "$y"
while [ $i -lt $n ]
do
        i=`expr $i + 1`
        z=`expr $x + $y`
        echo "$z"
        x=$y
        y=$z
done

Interpreting the fibonacci.sh file and executing it in terminal

tkanu025@hp:~/lab_solutions$ chmod +x fibonacci.sh
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 OOP Programs - 11

Mini project ideas for Operating System

GTU OS Program - 8