UP | HOME

Static analysis I-IV
Lecture 17-20

Table of Contents

Review

Questions about the last class?

Quiz

Will main_1 ever have a runtime error? What about main_2?

int f(int x, int t) {
  if (x < 10) {
    return x / t;
  } else {
    return x;
  }
}

int main_1() {
  int input = readInt();
  if (input > 10 || input < -10) {
    input *= -3;
  }
  print(f(7, input));
}

int main_2() {
  int input = readInt();
  if (input < 5) {
    input = (input - 10) * -1;
  }
  print(f(7, input));
}

Quiz Discussion

Main content

Author: Paul Gazzillo

Created: 2023-04-13 Thu 14:59