16 16 votes State whether the following statements are True or False with reasons for your answer: Coroutine is just another name for a subroutine. Compiler Design gate1994 compiler-design normal assembler true-false descriptive + – Kathleen 4.6k views answer comment Share Follow Print See all 3 Comments 3 3 Comments reply vishalshrm539 commented Sep 18, 2018 i edited by Shaik Masthan Nov 1, 2025 reply Follow flag A subroutine always starts its execution from the beginning(first line), but a co-routine starts from where it left off last time.This is why we say, the co-routine has multiple entry points whereas the sub-routine has only one.Yield 'remembers' where the co-routine is so when it is called again it will continue where it left off.For example: coroutine foo { yield 1; yield 2; yield 3; } print foo(); print foo(); print foo(); Prints: 1 2 3Note: Coroutines may use a return, and behave just like a subroutine coroutine foo { return 1; return 2; //Dead code return 3; } print foo(); print foo(); print foo(); Prints: 1 1 1Source - Stack Overflow 8 8 replyShare pavansan commented Nov 16, 2024 reply Follow flag now i am getting confusion so both are nsot same? 0 0 replyShare Taniii commented Aug 26 reply Follow flag i also have same doubt..it should be false? 0 0 replyShare Please log in or register to add a comment.
15 15 votes True. The subroutine is a special case of a co-routine. A co-routine is a generalized form of a subroutine which is non-preemptive multitasking. https://en.wikipedia.org/wiki/Coroutine srestha answered May 12, 2016 • edited Apr 23, 2021 by Lakshman Bhaiya srestha comment Share Follow See 1 comment 1 1 comment reply rahul sharma 5 commented Jan 22, 2018 reply Follow flag @srestha if coroutines are generalized form then can we say it is just another name of subroutine?It seems from your definition that coroutines can have multiples things and one of them is subroutine.So i think first is false 1 1 replyShare Please log in or register to add a comment.
3 3 votes TRUE: A subroutine and a function are essentially the same thing, with one difference: A function returns some sort of value (usually via the stack or CPU register), while a subroutine does not. Whether subroutine or function, it is a block of executable code, having exactly one point of entry. A co-routine is also a block of executable code, and, just like a subroutine, it has one point of entry. However, it also has one or more points of re-entry. ref: https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=4&cad=rja&uact=8&ved=0ahUKEwjawbP86t3WAhWLOo8KHXxhCpsQFgg5MAM&url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F24780935%2Fdifference-between-subroutine-co-routine-function-and-thread&usg=AOvVaw3yAD5Td224hZer_CQWxfAQ rishu_darkshadow answered Oct 7, 2017 rishu_darkshadow comment Share Follow 0 reply Please log in or register to add a comment.