[prev] 32 [next]

Exercise 3: Adding Interactively

Modify the program so that it behaves as follows:

int x;  int y;

void main(void) {
   printf("First number: ");
   scanf("%d", &x);
   printf("Second number: ");
   scanf("%d", &y);
   printf("%d\n", x+y);
}

Hints:

  • syscalls: read_int:5, print_str:4, print_int:1
  • read_int leaves the number read in $v0