I worked on the Life, Universe and Everything problem, the code is working fine on my machine but here it is showing as wrong answer. Kindly tell me the mistake
#include <iostream>
using namespace std;
int main() {
int a[50];
int i, x;
while(x != 42)
{
cout<<"processed nos : "<<x<<endl;
cin>>x;
}
return 0;
}
You’re not supposed to print anything other than the number recieved, so you must remove the whole processed nos part from your output, here at codechef, the output of your program should exactly match the output given in the sample test cases.
therefore, you just need to remove the processed nos text from your output, so that your line becomes:
cout<< x<< endl;
hope that helps.
1 Like
#include
using namespace std;
int main() {
int a[50];
int i, x;
while(x != 42)
{
cout<<"processed nos : "<<x<<endl;
cin>>x;
}
return 0;
}
i would give you a suggestion that you should take value of x once before the loop because by default it have some garbage value and yes you should not print anything other than required so please remove the text ie processed nos :.
1 Like
#include
using namespace std;
int main() {
int a[50];
int i, x;
while(x != 42)
{
cout<<"processed nos : "<<x<<endl;
cin>>x;
}
return 0;
}
i want to tell you that in codechef it not want extra thing
like processed nos.
and you are printing x value witout given value
so your program should be as follow;
#include
using namespace std;
int main() {
int a[50];
int i, x;
cin>>x;
while(x != 42)
{
cout<<x<<endl;
cin>>x;
}
return 0;
}
1 Like
include
using namespace std; int main() { int a[50]; int i, x; while(x != 42) { cout<<“processed nos : “<<x<<endl; cin=””>>x; }
return 0; } i want to tell you that in codechef it not want extra thing like processed nos. and you are printing x value witout given value so your program should be as follow;
include
using namespace std; int main() { int a[50]; int i, x; cin>>x; while(x != 42) {
cout<<x<<endl;
cin>>x;
}
return 0; }