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:
- Make sure your code covers all the different types of input in the code.
- 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.
- Name variables clearly to state their purpose.
- Avoid using in-built library function for strings, instead write your own logic for them.
- Avoid declaring arrays of arbitrary sizes, instead use malloc/calloc/realloc for the same.
- For any given problem try to find out all the solutions.
- 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.
- Given two numbers swap them.
- Given a number check if it is a palindrome or not.
- Given a number check if it is an Armstrong number or not.
- Given ‘n’, generate the nth prime number.
- Given ‘n’, generate n prime numbers.
- Generate the nth Fibonacci number.
- In an unsorted array of elements, search for a given key.
- In a sorted array of elements, search for a given key.
- Convert the given binary array into an unsigned integer.
- 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.
Here are the solutions to the above posted questions: Solutions_Sample_Questions_1