The input is N spaced integers. You have to read the input and print the input backwards. Source:(https://www.hackerrank.com/challenges/arrays-introduction/problem?isFullScreen=false)
One of the solutions is:
#include <iostream>
int main() {
int N,i=0;
std::cin>>N;
int *A = new int[N];
while(std::cin>>A[i++]);
// We have now iterated through the input and stored the
// integers in a dynamically allocated array.
// This line apparently prints out the Array (size N) backwards.
while(std::cout<<A[--N]<<' ' && N);
delete[] A;
return 0;
}
How does while(std::cout<<A[--N]<<' ' && N); print out the array A backwards?
How does it know to stop running the while loop?
What does the expression ' ' && N do? My intuition of && tells me that it should equate to TRUE or FALSE, but what does ' ' have to do with Boolean?