Q:

how coroutine scope builder flow works

Kotlin says   

runBlocking method blocks the current thread for waiting
coroutineScope just suspends, releasing the underlying thread for other usages. 
hence  runBlocking is a regular function and coroutineScope is a suspending function

fun main() = runBlocking { // this: CoroutineScope
    launch { 
        delay(200L)
        println("Task from runBlocking")
    }

    coroutineScope { // Creates a coroutine scope
        launch {
            delay(500L) 
            println("Task from nested launch")
        }

        delay(100L)
        println("Task from coroutine scope") // This line will be printed before the nested launch
    }

    println("Coroutine scope is over") // This line is not printed until the nested launch completes
}

in above example what i expect is :- 

runBlocking blocks main thread and launch will executed and it comes to delay(200L)
So, underlying coroutine is released and runs coroutineScope and comes to delay(500L) & delay(100L)
So, again underlying coroutine is released and it should print println("Coroutine scope is over"). 

This is what my understanding on runBlocking and coroutineScope.  Which is not working as expected. 
the Output is 
Task from coroutine scope
Task from runBlocking
Task from nested launch
Coroutine scope is over

Can anyone kindly explain in a easy way to understand this. 

A:

I modified your code a little
fun main() = runBlocking(Dispatchers. Default) {

    var i = 1
    launch {
        println("Task from runBlocking")
        while (i < 10) {
            delay(30L)
            println(i++)
        }
    }

    coroutineScope { // Creates a coroutine scope
        launch {
            delay(200L)
            println("Task from nested launch")
        }

        delay(100L)
        println("Task from coroutine scope") // This line will be printed before the nested launch
    }

    println("Coroutine scope is over")

}

Output

Task from runBlocking
1
2
3
Task from coroutine scope
4
5
6
Task from nested launch
Coroutine scope is over
7
8
9

the observation i made is,   

delay(100L) is equal to approximate 3 times delay(30L)
delay(200L) is equal to approximate 6 times delay(30L)

So, after 3 Task from coroutine scope and after 6 Task from nested launch is printed. 
then exactly after this Coroutine scope is over but you can still see the loop printed 7,8,9. 
This is because like runBlocking coroutineScope waits for all its members to execute by suspending underlying threads.  But understand, those threads first work on members of coroutineScope not on runBlocking.  
Hence, it is printing Task from coroutine scope and Task from nested launch before Coroutine scope is over

