Why we should not use GOTO statement?

All sort of Mainframes Interview Questions.
Post Reply
Makrand
Registered Member
Posts: 25
Joined: Wed Jul 24, 2013 3:14 pm

Why we should not use GOTO statement?

Post by Makrand »

In a recent interview among other questions this was one of the question which was asked - Why we should not use GOTO statement?

I was not sure about the answer, though I said,it usually depends on the standards of the particular company. But I think there is more to it - can someone please assist me in knowing the answer.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1885
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Why we should not use GOTO statement?

Post by Robert Sample »

In March 1968, Communications of the ACM published an article by Edsger Dijkstra titled "Go To Statement Considered Harmful". His article made the argument that the GO TO statement led to complicated logic, making programs harder to understand, as well as causing logic errors from jumping around in the code. If you Google "go to considered harmful" you can find and read the article.

These days, GO TO statements are rarely used due to the prevalence of structured programming and its reliannce on code that does not contain GO TO statements. Most languages still support them, however, so it is good to understand some of the history around GO TO statements.
Makrand
Registered Member
Posts: 25
Joined: Wed Jul 24, 2013 3:14 pm

Re: Why we should not use GOTO statement?

Post by Makrand »

Thanks Robert. I read the article and it's too detailed. Appreciate your help.
User avatar
CharlesFKelly
New Member
Posts: 7
Joined: Mon Feb 24, 2014 12:44 pm

Re: Why we should not use GOTO statement?

Post by CharlesFKelly »

Can you plz explore more on GO TO statement and its importance in C language.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “Interview Questions.”