Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a Go program to launch multiple goroutines and synchronize them using a WaitGroup.

Medium

Problem Statement

Write a Go program to launch multiple goroutines and synchronize them using a WaitGroup.

Sample Input

Three goroutines printing messages.

Sample Output

Goroutine 3
Goroutine 2
Goroutine 1
All goroutines finished.

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
package main import ("fmt" "sync") func printMessage(message string, wg *sync.WaitGroup) { // Implement the goroutine functionality } func main() { // Launch and synchronize goroutines using WaitGroup }
Log in or sign up to run or submit your code.Log inSign up
Input
Three goroutines printing messages.
Expected Output
Goroutine 3
Goroutine 2
Goroutine 1
All goroutines finished.