-1

POSIX bc has neither an else clause nor boolean operators. Is there any simple way to do simulate an else clause?

Roland
  • 7,525
  • 13
  • 61
  • 124

1 Answers1

1

Use a second if statement. The code

if (expression) {
   statement1
} else {
   statement2
}

in GNU bc does the same as

if (expression) {
   statement1
} 
if (expression == 0) {
   statement2
}

in POSIX bc.

Mike Pierce
  • 1,390
  • 1
  • 12
  • 35