Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Golang – For Loop use cases

For Loop is used for repeating a set of statements number of times.

Use Case 1:

package main  

import “fmt”  

func main() {  

   for a := 0; a 

      fmt.Println(a)  

   }  

}  

Output:

Use Case 2:

package main  

import “fmt”  

func main() {  

   for a := 1; a 

      for b := 2;b > 0; b– {  

         fmt.Print(a,” “,b,”\n”)  

      }  

   }  

}  

Output:

Use Case 3:

package main  

import “fmt”  

func main() {  

   s := 1  

   for s 

      s += s  

      fmt.Println(s)  

   }  

}  

Output:

The post Golang – For Loop use cases appeared first on Prwatech.



This post first appeared on Learn Big Data Hadoop In Bangalore, please read the originial post: here

Share the post

Golang – For Loop use cases

×

Subscribe to Learn Big Data Hadoop In Bangalore

Get updates delivered right to your inbox!

Thank you for your subscription

×