I have run this code in TC compiler after adding header file and deletinng “using namespace std;”
The output is exactly as desired,But the codechef judge is showing some error :/.
intput-
54
54
67
67
42
(exit)
#include
using namespace std;
int main()
{
int a;
while(a!=42)
{cin>>a;
cout<<a<<"\n";
}
return 0;
}
ar56
March 2, 2015, 9:19pm
2
Your program also prints 42.
You can implement it as -
cin>>a;
while(a!=42)
{
cout<<a<<endl;
cin>>a;
}
In your program, int a
is declared but not initialized so it may print 0 (or garbage value). Your program prints 42 also which should not be the case.
Check your code corrected and ACcepted here .
My code is as follows and I am also getting compilatiion error:
#include<stdio.h>
int main(){
int i;
for( ;scanf("%d",&i) && i!=42;printf("%d\n",i));
return 0;
}
Pls. help?
Please give submission link to your code or se “Enter code” feature of codechef.
I doubt your code is correctly show above @parth