PROGRAM - 1:
OUTPUT:
1
2
3
4
5
PROGRAM - 2:
OUTPUT:
1
2
3
4
5
package main
import "fmt"
func main() {
var x int
for x = 1; x <= 5; x++ {
fmt.Println(x)
}
}
OUTPUT:
1
2
3
4
5
PROGRAM - 2:
package main
import "fmt"
func main() {
//create a variable i with value 1
x := 1
// simply condition alone in for behave like while
for x <= 5 {
fmt.Println(x)
x += 1
}
}
OUTPUT:
1
2
3
4
5
No comments:
Post a Comment