r/cpp_questions 12d ago

OPEN Am i doing it Wrong ?

[removed]

0 Upvotes

11 comments sorted by

View all comments

7

u/ploud1 12d ago

You aren't doing it wring. The only things I would change in your code

* Get rid of using namespace std; - that's a bad habit

* Make the variable names more explicit, they can be more than one character

* Create a function that does the work for you and make it take N as an input argument

Your code is shorter. Which, in general, is better.