<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1596188457259603&amp;ev=PageView&amp;noscript=1">

Code quiz: Test your coding skills! [do you measure up?]

Posted by Magnus Unemyr on Jun 9, 2017 9:00:00 AM

In this blog post, I will give you a difficult coding task to crack. One of my colleagues presented it to the Atollic development team over a coffee break a few days ago, and I thought this could be an interesting problem for other developers to discuss over the coffee break as well! Are you up for a challenge to prove you are an expert developer?


In short, the following C code is designed to run on an Cortex-M4 based STM32 F4-Discovery board. Beneath the source code below, there are three questions that will test your coding skills. Here is the code:

uint32_t question1(uint32_t a, uint16_t* b)
  return ( (a + (uint32_t)*(b + 1)) | (uint32_t)*b) ^ (uint32_t)*b;

bool question2(uint32_t a)
  return (uint32_t)&a < *&a;


bool question3(const uint32_t* a)
  return (uint32_t)&a < (uint32_t)a;

int main(void)
  const uint32_t i = 0x10101010;

const uint32_t answer1 = question1(i, (uint16_t*)&i); const bool answer2 = question2(i); const bool answer3 = question3(&i); }

Considering the code above, please provide the correct answer to these questions:

Question 1: Which of the following answers is correct:

1: answer1 == 0x10100000

2: answer1 == 0x00001010

3: answer1 == 0x10102020

4: answer1 == 0x10103030

5: The code does not compile


Question 2: Which of the following answers is correct:

1: answer2 == true

2: answer2 == false

3: The code does not compile


Question 3: Which of the following answers is correct:

1: answer3 == true

2: answer3 == false

3: The code does not compile


Did you find the correct answers? Feel free to provide your feedback in the comment field below, and share it to colleagues and friends to test their skills too!

The new standard in ARM development