#include <stdio.h>
int main(void) { // your code here int n; while(1) { scanf("%d",&n); if(n==42) break; else printf("%d",n); }
return 0;
}
When you run this with the sample input from the question, does your output look exactly like the sample output?
Maybe the question shouldn’t be “What is problem in my code?” but “How to test my code?”. When testing on console by “hand”, it’s hard to find difference [error]. I think that @code_071096 do it in that way, testing on console…
I think the error would be obvious even when testing on a console, as that was how I spotted it.
Yes, you are right. Error is obvious for experiend user, for you, or for me, even without testing, but what about beginner[s]?
BTW On the other hand, shoudn’t the user tell as that his problem gone out? : http://www.spoj.com/status/TEST,code_071096/
Life universe and evrything(problem in my code?) i’m a beginner btw…
int main() {
int no;
cout<<“input number here” << no << endl; cin >> no;
while(no != 42){ cin >> no; if(no>100){ break; } if(no == 42){ break; } return; }
Also i use c++ so which type do i have to use like there are many like c++(g++ 4.3.2) etc ?