error: expected unqualified-id before ‘for’
Your for
loop is outside a function body.
Ok just to make this answer clear (since I made the rookie mistake too).
the for loop was outside int main()
(or any other function) along with everything else since main() sits by itself empty at the bottom of the code.
Sorry more than needed to be said for some but since this issue is more directed to newbies a more elaborate explanation is needed.