A french/american blog with some hungarian spices…
Alphabet Interview
All my alphabet interview experiences… or how to write a program to print the alphabet
alphabet version 3
May 19th
Third answer to my alphabet question:
#include <stdio.h> void main () { char Array[26] = { 'a', 'b', ... 'z'}; int i; for (i = 0; i <= 26; i++) { printf(%c\\n, *Array[i]); } exit; }
Download this code: alphabet_3.c
There is no typo in the transcript. What do you think? Is my question ‘too hard’? Is it not ‘appropriate’ for a ‘C’ developer position?
alphabet version 2
May 18th
Second answer… again, there is no typo, this is the pure transcript of the candidate’s answer.
main(argc, argv[]) { int i = 0; char a[26] = { 'a', 'b', 'c', ...'z'} for (i = 0; i <=26; i++) { printf("%d/n", a[i]%); } return; }
Download this code: alphabet_2.c
With this question, I’m realizing that array usage in C, is clearly not clear for everyone.
alphabet version 1
May 17th
First answer to my alphabet question:
void printAlphabet(void) { char a[21]; for (i = 0; i <26; i++) { if (i == 0) { a[i] = 'a'; } else { a[i] = a[i - 1]++; } } a[26] = '\\0'; printf("alphabet %s\\n", a); }
Download this code: alphabet_1.c
This might print the alphabet… but it will crash… I recopy the program as is… there is no typo from my side.
After this question, I asked more questions on how to use array in C. This person was terribly confused on how to use array in C.
My Alphabet question for interview
Apr 18th
Part of my job is to sometimes give interviews for people we want to hire. One of my favorite question is to ask the person to write a problem that will print the alphabet on the console. So let’s say I have a c file my_program.c, I want to be able to compile it, execute, and get the alphabet on the console. Something like: $./my_program
a
b
c
...
z
I really like this question as I think it’s easy enough to know if the person is able to write a simple program in C. I will post here the several code I got… and sometimes it’s really surprising.
What do you think about the question? Do you think it’s a dumb question? Is it too hard/easy?