CrazyEngineers
  • Can a function be nested?

    sushant005

    Member

    Updated: Oct 25, 2024
    Views: 1.3K
    We know that a function can be recursive but i want to know that does nested function possible in any programming language?
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • bill190

    MemberJul 23, 2010

    Yes. A function is just a collection of programming. And instead of writing all that programming each time you want to use it, you can stick it in a function. Then just use that function name in your program wherever you need to use it.

    So a program to "do your chores"...

    Main Program DoYourChores
    {
    Do ChoresList
    If weekend
    {
    Do ChoresList
    Relax
    }
    }

    Function ChoresList
    {
    Clean yard
    Wash dishes
    Take out trash
    }

    Function Relax
    {
    Watch TV
    }
    Are you sure? This action cannot be undone.
    Cancel
  • Morningdot Hablu

    MemberJul 23, 2010

    Realy
    Is it possible ?
    It means a function may be defined within main function ?
    Are you sure? This action cannot be undone.
    Cancel
  • bill190

    MemberJul 23, 2010

    Nested function defines...
    #-Link-Snipped-#
    Are you sure? This action cannot be undone.
    Cancel
  • arunravindran

    MemberAug 1, 2010

    Yes a function can be nested.
    Are you sure? This action cannot be undone.
    Cancel
  • sushant005

    MemberAug 2, 2010

    arunravindran
    Yes a function can be nested.
    Is this possible in C programming or JAVA?
    Are you sure? This action cannot be undone.
    Cancel
  • arunravindran

    MemberAug 2, 2010

    Hi,

    Sorry got my concepts wrong...i thought of function calls...a function cannot be defined within a main function as it gives declaration syntax error in C and Java...but nested functions concept exists...Correct me if I am wrong...
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register