Here is the first round of the 10 questions that will act as a preparation for the selection test Mission RnD 2018 Course. Please try to answer these questions in C. Here are some of the rules that will earn brownie points:

  1. Make sure your code covers all the different types of input in the code.
  2. Try to write the code as modular as possible. Divide your code into functions and try to avoid writing the entire function in the main function. Ideally, the main function should contain only reading the input and displaying the output.
  3. Name variables clearly to state their purpose.
  4. Avoid using in-built library function for strings, instead write your own logic for them.
  5. Avoid declaring arrays of arbitrary sizes, instead use malloc/calloc/realloc for the same.
  6. For any given problem try to find out all the solutions.
  7. Try to improve on your code by going back again and again to the same problem. It is but common that we will not arrive at the best solution in the first pass.

Questions:

  1. Given two numbers swap them.
  2. Given a number check if it is a palindrome or not.
  3. Given a number check if it is an Armstrong number or not.
  4. Given ‘n’, generate the nth prime number.
  5. Given ‘n’, generate n prime numbers.
  6. Generate the nth Fibonacci number.
  7. In an unsorted array of elements, search for a given key.
  8. In a sorted array of elements, search for a given key.
  9. Convert the given binary array into an unsigned integer.
  10. Convert the given unsigned integer into a binary array.

We hope you welcome the new year with these questions. You may have already solved most of these questions in your lab exercises but we want you to comply by the seven principles stated above. We will release a set of answers to these questions on 26th of January 2017 at 7 P.M. In case of doubts, try to debug the issue as much as you can and in case you are stuck somewhere please feel to post questions in college wise groups or on this post.

 

UPDATE:

Here are the solutions to the above posted questions: Solutions_Sample_Questions_1