The code you write in your for loop is wrong.
To give you an idea let us take your example. Initially your list is
42 -> 36 -> 14 -> 17 -> 48 -> 36
| |
ELEhead ELEtail
Just before the for loop: ELEtail points to 36 (last element) and ELEhead points to 42 (first element).
Now after the first iteration of your for loop : ELEtail points to 42 and ELEhead points to 36(second element of initial list) and the list becomes
42 -> 36 -> 14 -> 17 -> 48 -> 36 -> 42
| |
ELEhead ELEtail
First and the last 42 in above example are same element. Hence it makes an infinite loop.
Now to reverse the link list, you require only one pointer for the head of the reversed linklist. Every time you encounter a new element in the original linklist just enter it at the head of the reversed linklist. And your linklist will be reversed when you insert the last element of original linklist at the head of the new linklist. And for that you don't even require to know the length of the original list. This will save your first loop where you are calculating the length of the linklist.