long mult(long m, long n) { long result = 0; while (m > 0) { if (m & 1) result += n; m = m >> 1; n = n << 1; } return result; } |
Suppose you are given the truth table below, where - indicates don't-care values.
w x y z | f |
0 0 0 0 | - |
0 0 0 1 | 1 |
0 0 1 0 | 0 |
0 0 1 1 | 0 |
0 1 0 0 | 0 |
0 1 0 1 | 1 |
0 1 1 0 | 0 |
0 1 1 1 | - |
1 0 0 0 | - |
1 0 0 1 | 0 |
1 0 1 0 | 0 |
1 0 1 1 | 1 |
1 1 0 0 | 0 |
1 1 0 1 | - |
1 1 1 0 | 0 |
1 1 1 1 | 1 |
Produce a Marie program with behaviour corresponding to the C program shown below.
#include <stdio.h> int main() { int x = 10; int y = 20; int z = 0; scanf("%d", &x); scanf("%d", &z); if (x > y) { if (x > z) { z = x; } printf("%d", z); } else { printf("%d", y); } } |