Back to Programming Languages forum
Is it possible to break a while loop using '\n' ? eg: cin>>arr[i]; while(arr[i]!='\n') {
}
Does it work ? It does NOT show an error,niether does it work.
There's nothing in what you've written that will break out of the while loop. How about
cin>>arr[i];
while(arr[i]!='\n'){
cin>>arr[i];
}
It's actually the April fools problem, the input was
3(number of test case)
3 5 8
8 9 7 8
5 4
I solved this by putting a zero to separate the array, and then inputting with while(ar[i]!=0) .
I wanted to know if we can take input without the 0.
After reading the number of test cases, I read a line at a time.
Now that you've solved it, you can look at how others have done it.