(So far, 51 people got it right out of 441 for a success rate of 11%)
(Thank you to Jason Sachs for submitting this question)
What does kapow()
return in this C program?
#include <stdint.h> uint32_t howjadoo(uint32_t prevsum, uint16_t command, uint16_t response) { return prevsum + (command - response); } uint32_t kapow() { return howjadoo(100000, 10001, 10002); }
- Comments
- Write a Comment Select to add a comment
Interesting quiz! One quick correction to the explanation section, which says "On machines where an int is 8 or 16 bits,...". The int type in C cannot be only 8-bit wide even on 8-bit CPU. This is because the C Standard says that "Basic signed integer type. Capable of containing at least the [−32,767, +32,767] range."
Good point I didn't know about
Well, I could understand the result if the quiz was written using "int", "unsigned int", "long" and "unsigned long" which are processor dipendent but every I looked it says that uint16_t is 2 bytes and uint32_t is 4 bytes regardless the processor. I am confused.
To post reply to a comment, click on the 'reply' button attached to each comment. To post a new comment (not a reply to a comment) check out the 'Write a Comment' tab at the top of the comments.
Please login (on the right) if you already have an account on this platform.
Otherwise, please use this form to register (free) an join one of the largest online community for Electrical/Embedded/DSP/FPGA/ML engineers: