当前位置:网站首页>Go language self-study series | if else statement in golang
Go language self-study series | if else statement in golang
2022-07-03 15:41:00 【51CTO】
Video source :B standing 《golang Introduction to project practice [2021 newest Go Language course , There is no nonsense , Dry only ! Ongoing update ...]》
Organize the teacher's course content and test notes while studying , And share it with you , Infringement is deleted , Thank you for your support !
Attach summary sticker : Go Language self-study series | Summary _COCOgsta The blog of -CSDN Blog
go In language if else Statement can be selected according to a given condition .
go Linguistic if else Sentence syntax
go Language if else Statement instance
Compare the size of two numbers
Running results
Judge whether a number is odd or even
package main
import "fmt"
func f2() {
var s int
fmt.Println(" Enter a number :")
fmt.Scan(&s)
if s%2 == 0 {
fmt.Print("s It's even \n")
} else {
fmt.Print("s Not even numbers \n")
}
fmt.Print("s The value of is :", s)
}
func main() {
f2()
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
Running results
Judging whether a person is an adult
Running results
Special way of writing , stay if Add execution statement before
Running results
go Language if Statement use prompt :
- You do not need parentheses to enclose conditions
- Curly braces {} There must be , Even if there is only one line of statement
- The left parenthesis must be in if or else On the same line
- stay if after , Before conditional statement , You can add variable initialization statements , Use ; separation
边栏推荐
- [cloud native training camp] module VIII kubernetes life cycle management and service discovery
- 阿特拉斯atlas扭矩枪 USB通讯教程基于MTCOM
- Microservices Seata distributed transactions
- App移动端测试【3】ADB命令
- The markdown file obtains the pictures of the network and stores them locally and modifies the URL
- 深度学习之三维重建
- Wechat payment -jsapi: code implementation (payment asynchronous callback, Chinese parameter solution)
- Kubernetes vous emmène du début à la fin
- [系统安全] 四十三.Powershell恶意代码检测系列 (5)抽象语法树自动提取万字详解
- 利用MySQL中的乐观锁和悲观锁实现分布式锁
猜你喜欢

Digital image processing -- popular Canny edge detection

Seckill system 2 redis solves the problem of distributed session

Digital image processing -- popular understanding of corrosion and expansion

Concurrency-01-create thread, sleep, yield, wait, join, interrupt, thread state, synchronized, park, reentrantlock

Popular understanding of random forest

Jvm-02-class loading subsystem

QT use qzxing to generate QR code

Microservices Seata distributed transactions

《微服务设计》读书笔记(下)

C语言刷题~Leetcode与牛客网简单题
随机推荐
Go语言自学系列 | golang switch语句
Popular understanding of gradient descent
Halcon and WinForm study section 1
Under VC, Unicode and ANSI are converted to each other, cstringw and std:: string are converted to each other
Win32 create window and button (lightweight)
Jvm-02-class loading subsystem
[combinatorics] combinatorial identities (recursive combinatorial identities | sum of variable terms | simple combinatorial identities and | sum of variable terms | staggered sums of combinatorial ide
秒杀系统1-登录功能
[daily training] 395 Longest substring with at least k repeated characters
CString的GetBuffer和ReleaseBuffer使用说明
Final review points of human-computer interaction
Halcon与Winform学习第一节
QT common sentence notes
socket. IO build distributed web push server
Create gradle project
请做好3年内随时失业的准备?
GCC cannot find the library file after specifying the link library path
UnityShader——MaterialCapture材质捕捉效果 (翡翠斧头)
详解指针进阶2
The difference between mutually exclusive objects and critical areas