+ 2
What's wrong with this code??? Expected output is same but still it is not correct.
#include <iostream> using namespace std; int main() { int n; cin >> n; for(int i =n ; i>=1 ; i--) { cout<<i; if(i==1) { break; } cout<< "\n"; if(i%5==0) { cout << "Beep \n"; } } return 0; }
3 Answers
+ 4
cout << "Beep\n";
+ 5
Don't print a space after the Beep and everything should be fine.
+ 1
Yeah there is extra space when u printing beep between beep and \n . That's why it failed in test case actually in such type of problems you have to take care of input amd outputs formats . And avoid your code for writing unnecessary lines .