Hello everyone, this is my first post here so I'll give a little background about myself. I know next to nothing about programming but I am attempting to teach myself C++ using lecture notes and assignments from MIT's CS department.
With that out of the way, here is my question. This program won't compile and I'm not sure why since I declared my variable 'N.' Do I need to declare it within the while loop? If so I don't understand why. Thanks!
Code:
#include <iostream>
using namespace std;
int main () {
int N=0;
cin >> N;
while(N>0)
{
cout << N%5 == 0 && N%-1 ? N/5 : -1 << "\n";
}
return 0;
}