c语言变量类型和范围_C变量和类型

C语言是一种静态类型语言,变量在声明时必须指定类型。整数类型包括:char, int, short, long等,根据环境不同有不同的取值范围。无符号整数在超出范围时会溢出。编译器在声明错误类型或超出范围时会发出警告。浮点数如float和double用于表示带小数点的数值,它们的精度和范围取决于具体实现。" 132593390,19694583,超级终端在嵌入式系统开发中的应用,"['嵌入式开发', '单片机', 'stm32', '串口通信']
摘要由CSDN通过智能技术生成

c语言变量类型和范围

C is a statically typed language.

C是一种静态类型的语言。

This means that any variable has an associated type, and this type is known at compilation time.

这意味着任何变量都具有关联的类型,并且该类型在编译时是已知的。

This is very different than how you work with variables in Python, JavaScript, PHP and other interpreted languages.

这与处理Python,JavaScript,PHP和其他解释语言中的变量的方式非常不同。

When you create a variable in C, you have to specify the type of a variable at the declaration.

在C语言中创建变量时,必须在声明中指定变量的类型。

In this example we initialize a variable age with type int:

在此示例中,我们使用int类型初始化变量age

int age;

A variable name can contain any uppercase or lowercase letter, can contain digits and the underscore character, but it can’t start with a digit. AGE and Age10 are valid variable names, 1age is not.

变量名可以包含任何大写或小写字母,可以包含数字和下划线字符,但不能以数字开头。 AGEAge10是有效的变量名,不是1age

You can also initialize a variable at declaration, specifying the initial value:

您还可以在声明时初始化变量,并指定初始值:

int age = 37;

Once you declare a variable, you are then able to use it in your program code, and you can change its value at any time, using the = operator for example, like in age = 100;, provided the new value is of the same type.

声明变量后,便可以在程序代码中使用它,并且可以随时使用=运算符来更改其值,例如age = 100; ,前提是新值的类型相同。

In this case:

在这种情况下:

#include <stdio.h>

int main(void) {
	int age = 0;
	age = 37.2;
	printf("%u", age);
}

the compiler will raise a warning at compile time, and will convert the decimal number to an integer value.

编译器将在编译时发出警告,并将十进制数转换为整数值。

The C built-in data types are int, char, short, long, float, double, long double. Let’s find out more about those.

C内置数据类型为intcharshortlongfloatdoublelong double 。 让我们进一步了解这些。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值