Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

general C++ question

  • 03-04-2009 3:48am
    #1
    Closed Accounts Posts: 2


    I was wondering if there was a limit to how many nested statements you could put in a program? For instance, nesting an if...else statement within a switch statement that is within a while statement. Any enlightenment would be appreciated.


Comments

  • Registered Users, Registered Users 2 Posts: 6,240 ✭✭✭hussey


    I was wondering if there was a limit to how many nested statements you could put in a program? For instance, nesting an if...else statement within a switch statement that is within a while statement. Any enlightenment would be appreciated.

    I don't think so - would be all compiler/memory related, but I would assume a couple of hundred thousand


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    I was wondering if there was a limit to how many nested statements you could put in a program?

    Not aware of a limit, but from a coding style standpoint you should avoid doing too many.

    If you need a large number then a recursive method/function would probably be better (at least in maintaining the code).


  • Registered Users, Registered Users 2 Posts: 981 ✭✭✭fasty


    For the sake of programming style, I would say stick to 2 or 3 nested statements.

    I guess if you had LOTS of local variables in the mix or a few large ones, you'd have stack overflow to worry about. But then the same could be said of recursion...


Advertisement