当前位置:网站首页>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
边栏推荐
- 阿特拉斯atlas扭矩枪 USB通讯教程基于MTCOM
- 使用AUR下载并安装常用程序
- 找映射关系
- CString的GetBuffer和ReleaseBuffer使用说明
- Visual upper system design and development (Halcon WinForm) -5 camera
- 互斥对象与临界区的区别
- Tensorflow realizes verification code recognition (II)
- Problems of CString in multithreading
- Introduction to redis master-slave, sentinel and cluster mode
- Go语言自学系列 | golang中的if else if语句
猜你喜欢
软件逆向破解入门系列(1)—xdbg32/64的常见配置及功能窗口
Summary of concurrent full knowledge points
[系统安全] 四十三.Powershell恶意代码检测系列 (5)抽象语法树自动提取万字详解
Visual upper system design and development (Halcon WinForm) -4 Communication management
Visual upper system design and development (Halcon WinForm) -5 camera
Digital image processing -- popular understanding of corrosion and expansion
Digital image processing -- popular Canny edge detection
百度智能云助力石嘴山市升级“互联网+养老服务”智慧康养新模式
C语言刷题~Leetcode与牛客网简单题
Seckill system 3- product list and product details
随机推荐
Microservices - load balancing ribbon
Reentrantlock usage and source code analysis
求字符串函数和长度不受限制的字符串函数的详解
Popular understanding of ovo and ovr
Introduction series of software reverse cracking (1) - common configurations and function windows of xdbg32/64
Popular understanding of linear regression (II)
Microservice sentinel flow control degradation
Detailed pointer advanced 2
Tensorflow realizes verification code recognition (III)
秒殺系統3-商品列錶和商品詳情
如何使用 @NotNull等注解校验 并全局异常处理
CString的GetBuffer和ReleaseBuffer使用说明
《微服务设计》读书笔记(下)
Halcon and WinForm study section 2
The markdown file obtains the pictures of the network and stores them locally and modifies the URL
Second kill system 3 - list of items and item details
需要知道的字符串函数
XWiki Installation Tips
WinDbg analysis dump file
Custom annotation