Question

Differentiate between the following with the help of suitable example for each :
a. Co-routines and subroutines
b. Co-routines and threads

30 Nov 2023
Answer :
Word Count : 580

a. Co-routines and Subroutines:

Subroutines:
A subroutine, also known as a function or method in programming, is a block of code designed to perform a specific task. It is a self-contained unit of code that can be called from other parts of the program, and it usually takes parameters and returns a value. Subroutines are used to break down a program into smaller, more manageable pieces, promoting code reusability and modularity.

Example in C:
```c
#include <stdio.h>

// Subroutine to calculate the square of a number
int square(int num) {
    return num * num;
}

int main() {
    int result = square(5);
    printf("Square: %d\n", result);
    return 0;
}
```

Co-routines:
Co-routines, on the other hand, are a more advanced concept that allows multiple entry points for suspending and resuming execution at certain points. They are designed to be more cooperative in nature, allowing for non-preemptive multitasking. In co-routines,

____ ____ ___ _____ _______.
_____ ______ __________ _________ _______.
_____ ________ __________ ______ ____ ________ _____ _______ __________ _____ _______.
_______ __________ ____ _____ ______ ____ _________.
________ _________ ___ ________ _______ ___ _____.
____ ____ ________ __________ ____ __________.
___ ______ ______ _______ _______ ________ _______ ________.
______ ______ __________ _______ _________.
________ _______ _________ ______ _______.
________ ______ ___ _______ _____ ________.
____ ______ ___ _______ _________ _____ ______ ___ _______ ___.
_____ ______ ___ _______ ____ _____.
_________ ________ ______ _____ ___ ____ _______ _______ __________ ________ _______ ____.
_________ _______ ____ _______ ________ __________ ________ ______ __________ _____.
_________ __________ ____ _____ ____ _________ _________ ____ ___ _______ _____.
______ _____ ________ __________ _______ _________ _____ ________ __________.
____ _________ ________ __________ ____.
__________ _____ ______ _________ ____ ________ _________ ________ _______.
_____ ___ ___ _____ ______ _________ __________ ________ _____ _____.
____ _____ __________ ____ ______ ________ ______ ___ __________ ___ _________ _________.
______ _______ __________ _______ ______ _____.
________ ___ ______ _____ ______ ___ ______ ___ ________ _____ ____ __________.
______ __________ ______ _______ _________ ___ ____ _________.
________ _________ ________ ______ _______ _______ _________.
______ _________ ___ ________ ___.
__________ ____ ______ _________ ____ ___.
_________ ___ _______ ___ _____ ______.
___ _____ ___ ____ _____ ________ ___ ___ ______ ______.
_____ ____ _____ __________ __________ ______ __________ ____.
_______ ___ _______ _________ ______ ______ ____ _________ _________ _________ _________.
_________ _________ ______ _______ __________ ________.
___ __________ _______ ________ ______ ______.
_______ ________ ____ __________ ____ ___.
__________ ___ __________ ____ _______ _______ _________ ____ ___ _________ ______.
_________ __________ _______ ___ _____ _________.
_____ ______ _________ __________ __________ _________ _________ _______ ________ ______ __________.
________ ________ ______ _______ _________ ______ ____ _____ _______.
___ ______ ____ ________ ___ _______ ________.
________ _____ _________ ________ ________ __________ _____ ______ ___.
____ _____ __________ __________ ______.
________ _____ _____ __________ ______ __________ ______ ___ _______ ___ __________ __________.
____ _________ ________ _____ _________ _____ ____ ____ ___ ___.
___ ____ ____ ______ _______ __________ ____ _______ ________ ________ ______.
_______ __________ _____ _______ ________ __________ __________ _________.
____ _______ ____ ___ _______ ______.
___ __________ _________ _________ __________ _________ ________ ___ ___ ___ _____ __________.
_______ ______ _________ _______ ___ _____ ______.
_________ ________ _______ ___ ______.
_____ _________ _______ _________ ____ _______ _________ _________ _______ ______ _______.
_________ _____ _______ _______ _____ _________ ___ ___ ___.
________ _______ ____ __________ ____ _____ _____.
IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
Top
📞
Call Support Instant phone assistance IGNOU MCS 201 2023 - Differentiate between the following with the help of suitable example | IGNOU Academy
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→