I'm trying to do this in Ubuntu virtualbox with a shell text:
#!/bin/bash
n1=3.5
n2=3.6
n3=3.7
n=3
let promedio=n1+n2+n3/3
echo $promedio
is about the Average student grade. But then the terminal shows the error:
line 7: let: 3.5: syntax error: invalid arithmetic operator (error token is ".5")
Why? I can't do the + with numbers. What can I do?
I was reading about BC command but I don't know where it goes.
EDIT: I tried adding | BC at the end but is the same error. Also I tried looking at a post about this but they use something different I really don't understand because I'm really new with Ubuntu. They use the $echo
or something like that but the code I'm using is different.
echo | bc
form better. It’s covered by the most upvoted steeldriver’s answer. But you are right… I’ve upvoted it right now.