Your code does not return the correct output for the sample input.
For this input:
1
2
88
42
99
Your code will print:
1288
The correct output is:
1
2
88
The difficulty that you are having is caused by the fact that you are using the console for input. The console allows you to type input to stdin as well as display output from stdout.
If you redirect your stdin and stdout to a file then you will accurately see what is being entered from stdin and being output to stdout.
To fix your output issue you should change your printf statement by adding a newline character to the end of it:
printf("%d\n",a);
Why have you chosen these conditions for your while loop?
while(a>0&&a!=42)