showing wrong answer

#include<stdio.h>
#include<stdlib.h>
int main()
{
int i=0,n=0;
for(i=0;i<10;i++)
{
scanf("%d",&n);
if(n!=42)
printf("%d",n);
else
exit(1);
}
return 0;
}

you are doing it wrong…problem specifies nothing about how many numbers will be supplied…you are assuming it to be 10. take a infinite loop, and it is encouraged not to use exit(1) this may cause non-zero exit error…everything else is fine…