1. C语言基本数据类,《C语言程序设计》——基本数据类型

c09cf39a37234ac9b3ae5f6feaf304a8.png

今天我想要分享给大家的是C语言程序设计第一章——基本数据类型的内容。今天的主要内容有四部分,分别是常量与变量,简单的屏幕输出,数据类型和如何计算变量或数据类型所占空间的大小。Today I want to share with you the first chapter of C programming - the content of basic data types. Today, there are four parts, namely constant and variable, simple screen output, data type and how to calculate the space occupied by variables or data types.

No.1 常量与变量

5b725fa7852b46c0cbd2d95a458d70a4.png

1.定义变量的一般形式:类型关键字 变量名;

2.关键字(Keyword):C语言预先规定的、具有特殊意义的单词

Define the general form of variable: type keyword variable name;

Keyword: a word with special meaning that is pre-defined by C language

bff7e80bd82eeaea16ec4d953064d38a.png

3.一个C 程序必须且只能有一个用main作为名字的函数,这个函数成为主函数;main后面圆括号内的void表示它没有函数参数;main前面的int表示3.函数执行后会返回操作系统一个整数型,在main函数的函数体中的最后一条语句使用return语句返回了这个值,通常返回0表示程序正常结束。

4.C语言允许在定义变量的同时对变量初始化(为其赋初值)

A C program must and can only have one function with the name of main, which becomes the main function; Void in parentheses after main means that it has no function parameters; After the function is executed, it will return an integer type of the operating system. The last statement in the body of the main function returns this value with a return statement. Usually, it returns 0, which indicates the normal end of the program.

C language allows variables to be initialized (initial value assigned) while defining variables

No.2简单的屏幕输出

aea37fe1c2cfe0f5f94f29e7c55f9371.png

No.3数据类型

2ac2400240c23bfbca97008a46e180b9.png

5.程序第一行以#开头而未以分号结尾的不是C语句,而是C的编译预处理命令;尖括号内的文件称为头文件,h为head之意,std为standard之意,i为input之意,o为output之意;编译预处理命令#include可使头文件在程序中生效,它的作用是:将写在尖括号内的输入/输出函数的头文件stdio.h包含到用户源文件中。

6.字符串:用一对双引号括起来的若干字符。

The first line of the program starts with #, but does not end with semicolon. It is not C statement, but C compilation preprocessing command; The files in angle brackets are called header files, H means head, STD means standard, I means input, O means output; The compiler preprocessing command # include can make the header file effective in the program. Its function is to include the header file stdio. H of the input / output function written in angle brackets into the user source file.

String: a number of characters enclosed in a pair of double quotation marks.

No.4如何计算变量或数据类型所占内存空间的大小

cf47aa0c41637c4794f1b3851b8ffb8f.png

7.一个字节(Byte)可以表示的整数最小为0,最大为255,一个字节等于8个二进制位(bit),也称比特。bit是binary digit二进制数的缩写,位是衡量物理存储器容量的最小单位。要想准确计算某种类型所占内存空间的字节数,需要使用sizeof()运算符。

A byte can represent an integer with a minimum of 0 and a maximum of 255. A byte is equal to 8 binary bits, also known as bits. Bit is the abbreviation of binary number, and bit is the smallest unit to measure the capacity of physical memory. To accurately calculate the number of bytes occupied by a certain type of memory, you need to use the sizeof () operator.

参考资料:文字:百度;图片:微博;翻译:百度翻译

本文由LearningYard新学苑原创,部分图片文字来自网络,如有侵权请联系。

举报/反馈

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值