#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.
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; }
thanks
for helping me
you can also look for this discussion on the same problem
http://discuss.codechef.com/questions/7640/why-do-i-get-wrong-answer
@ma5termind linked question is not the correct one for discussing problems
do not use conio.h
header on CodeChef
mention not bro