Doubt in the code largest k elements

it is still taking the input
Try to run it on your local machine
i m sending the code

pls check

No I ran it on the compiler and printed an extra letter outside the loop, and the letter got printed , so the loop does end at end of input. See https://ide.codingblocks.com/s/201834