You are not logged in. Please login at www.codechef.com to post your questions!

×

CodeChef showing wrong answer

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;
}

asked 10 Apr '15, 21:58

sanjeet17's gravatar image

0★sanjeet17
11
accept rate: 0%

edited 09 Jul '15, 09:36

vicky002's gravatar image

1★vicky002 ♦♦
2561313


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.

link

answered 10 Apr '15, 22:16

shiva1k95_10's gravatar image

3★shiva1k95_10
116412
accept rate: 0%

    #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; }

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 :.

link

answered 30 May '15, 17:38

binay_misra's gravatar image

1★binay_misra
84215
accept rate: 5%

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; } 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 <iostream>

using namespace std; int main() { int a[50]; int i, x; cin>>x; while(x != 42) {

cout<<x<<endl;
cin>>x;

}
return 0; }

link

answered 30 May '15, 18:18

vipin123's gravatar image

0★vipin123
2548
accept rate: 20%

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; } 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 <iostream> using namespace std; int main() { int a[50]; int i, x; cin>>x; while(x != 42) {

cout<<x<<endl; cin="">>x; } return 0; }

link

answered 05 Jul '15, 20:33

v1i9n9a9y's gravatar image

0★v1i9n9a9y
11
accept rate: 0%

edited 05 Jul '15, 20:47

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,822
×24

question asked: 10 Apr '15, 21:58

question was seen: 1,649 times

last updated: 09 Jul '15, 09:36