#include<stdio.h>
#include<conio.h>
void main()
{
int n;
scanf("%d",&n);
while(n!=42)
{printf("/n%d",n);
scanf("%d",&n);
}
getch();
}
Okay here you go.
-
The print statement should be like printf("%d\n", n) since you need to leave a live AFTER every output and not before.
-
You should remove the getch(); because the program wonβt end unless it accepts another input after the specified inputs in the question.
-
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 β¦
#include int main() { int n ; while(1){ scanf("%d",&n) ; if(n == 42) break ; printf("%d\n",n) ; } return 0; }
1 Like
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
thanks
for helping me
mention not bro