Why is my code wrong?

void main()
int n;

Okay here you go.

  1. The print statement should be like printf("%d\n", n) since you need to leave a live AFTER every output and not before.

  2. You should remove the getch(); because the program won’t end unless it accepts another input after the specified inputs in the question.

  3. Also, I changed the void main() to int main() and added a return 0; at the end.

I got AC with the following changes.

1 Like

Hello aman_joshi668

although additya1998 has mentioned all the problem in your code here is the AC version of your code with minimal changes … :slight_smile:


int main() {
	int n ;
		scanf("%d",&n) ;
		if(n == 42)
			break ;
		printf("%d\n",n) ;
	return 0;

1 Like

for helping me

you can also look for this discussion on the same problem


@ma5termind linked question is not the correct one for discussing problems

do not use conio.h header on CodeChef :wink:

mention not bro :slight_smile:

I have not used conio.h in my code … not in the mentioned link … :slight_smile: