main()
{
if()
{
   if()
    {
     if()
      {
          something ()
        /* something so that the program executes the last line means last printf without using goto ststement */
       }
     }
  }
printf("hello");
}

Recommended Answers

Homework detected, even though you haven't asked a question yet.

If this were real code, I'd say go ahead and use goto. The reasons to avoid doing so don't really apply in this particular situation, and it saves time, space and clutter.

Jump to Post

All 2 Replies

Homework detected, even though you haven't asked a question yet.

If this were real code, I'd say go ahead and use goto. The reasons to avoid doing so don't really apply in this particular situation, and it saves time, space and clutter.

If this were real code, I'd say go ahead and use goto.

If this were real code, I'd say that it should probably be refactored into multiple functions rather than straight nested conditionals. Though I can't help but notice that there's not a loop in the example cod in the first place. ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.