Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

homework help please!

Name: Anonymous 2013-01-12 3:05

Why is my code not working? It's supposed to calculate 2+7 but just returns some weird number. Help?


#include <stdio.h>
#define dw unsigned long
dw t = 0; dw c = 0;
unsigned char ipl[] = {1,4,6,9};
dw mb[] = {2,7};
dw n(dw a){c++; if(c > sizeof(mb)) c=0;return a;}
dw p(dw a){c--; if((int)c < 0)c = sizeof(mb);return a;}
dw q(dw a){t=mb[c];p(a);return t;}
dw r(dw a){mb[c]=a;n(a);return a;}
dw a(dw a){return q(t+a);}
dw s(dw a){return q(t-a);}
dw m(dw a){return q(t*a);}
dw dl(dw a){return q(((dw)(t/a)));}
dw d(dw a){printf("{%u}",t);return a;}
dw z(dw a){return a;}
dw (*i[])(dw a) = {z,q,r,p,n,a,s,m,dl,d,z};
int main(int argc, char ** args){
     dw j;
     for(j=0;j<=sizeof(ipl);j++) (*i[(j % sizeof(i))])(mb[c]);
     return t;
}

Name: Anonymous 2013-01-12 3:45

You did not make a proper header with your name, my name, and the date in it: Minus 10 points.
You did not name your variables descriptively: Minus 10 points.
You did not comment your code: Minus 10 points.
You did not adhere to Hungarian notation: Minus 10 points.
You did not follow proper presentation conventions: Minus 10 points.
Your code does not work: Minus 1 point.

Total: 49 Points.
Final Grade: F MINUS

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List