This is not the current version of the class.

Datarep1 Activity

Which of the following codes will have the same effect as the normal int add(int a, int b), for all inputs? And why?

A.

int add(int a, int b) {
    return b + a;
}

B.

short add(short a, short b) {
    return a + b;
}

C.

unsigned add(unsigned a, unsigned b) {
    while (b > 0) {
        ++a;
        --b;
    }
    return a;
}

D.

extern const unsigned char add[] = { 0x8d, 0x04, 0x37, 0xc3 };