c语言语言教程0基础

Hey, Folks here I am back with my second article on C language. Hope you are through with my previous article C language - History, Popularity reasons, Characteristics, Basic structure etc. In this one, I will cover some fundamental concepts of C Language namely Variables, Tokens, Operators in C language.

嘿,伙计们,我回来了第二篇有关C语言的文章。 希望您能读完我以前的C语言文章-历史,流行原因,特征,基本结构等 。 在这一篇中,我将介绍C语言的一些基本概念,即C语言中的变量,标记,运算符

Let’s get started...

让我们开始吧...

1)变量 (1) Variables)

They are temporary memory locations allocated during execution of the program. As the name suggests it is an entity whose value may change during program execution.

它们是在程序执行期间分配的临时内存位置。 顾名思义,它是一个在程序执行期间其值可能会更改的实体。

Rules for variable name

变量名规则

  1. It does not have a space between characters.

    字符之间没有空格。

  2. Collection of alphabets, digits, and underscore (_).

    字母,数字和下划线(_)的集合。

  3. The first character should be either alphabet or underscore (_).

    第一个字符应为字母或下划线(_)。

  4. No other special symbol except underscore (_).

    除下划线(_)外,没有其他特殊符号。

  5. Keywords cannot be used as variable name.

    关键字不能用作变量名。

Declaration of variable

变量声明

Syntax:

句法:

datatype variable_name;

Example:

例:

int a;

It tells the user what is the data type of a declared variable or what type of values it can hold.

它告诉用户声明的变量的数据类型是什么或它可以保存的值的类型。

Initialization of a variable

初始化变量

The process of assigning any value to any variable.

将任何值分配给任何变量的过程。

Example:

例:

int a = 5;

2)代币 (2) Token)

The basic and smallest unit of C program is token.

C程序的基本最小单位是令牌。

Token includes :

令牌包括:

  1. Keywords

    关键词

  2. Identifier

    识别码

  3. Constants

    常数

  4. String Constant

    字符串常量

  5. Operators

    经营者

  6. Special Symbols e.g: _ , @ , *

    特殊符号,例如:_,@,*

1) Keywords or Reserve words

1)关键字或保留字

These are those words whose meaning is already explained to the compiler.

这些是已经向编译器解释其含义的单词。

They can’t be used as a variable name because if we do so that means we are defining the new meaning to the compiler which the compiler does not allow.

它们不能用作变量名,因为如果这样做,则意味着我们正在为编译器定义编译器不允许的新含义。

2) Identifier

2)识别码

They are the name given to programming elements such as array, function, variable. Same rules as of variable name.

它们是诸如数组,函数,变量之类的编程元素的名称。 与变量名相同的规则。

3) Constant

3)常数

Entities whose value does not during the execution of a program.

其值在程序执行期间不存在的实体。

4) String constant

4)字符串常量

Collection of character enclosed by a double inverted comma. e.g.: "abc"

用双反逗号括起来的字符的集合。 例如: “ abc”

5) Operators

5)运营商

They are used to perform arithmetic and logical operations by ALU.

它们由ALU用于执行算术和逻辑运算。

Example:

例:

 a+b

Here, a and b are operands and + is an operator.

在这里, a和b是操作数,而+是运算符。

C language has very rich operators. Many different types of operators are available in C language for different mathematical computations.

C语言具有非常丰富的运算符。 C语言提供了许多不同类型的运算符,用于不同的数学计算。

They are mainly of three types:

它们主要分为三种类型:

.minHeight{ min-height: 250px; } @media (min-width: 1025px){ .minHeight{ min-height: 90px; } } .minHeight{ min-height: 250px; } @media (min-width: 1025px){ .minHeight{ min-height: 90px; } }

Operators itself is a separate topic which needs to be covered in detail.

运营商本身是一个单独的主题,需要详细介绍。

So, here we get started.

所以,我们开始。

Unary operators

一元运算符

They require only one operand for execution, it includes :

它们只需要一个操作数即可执行,其中包括:

  1. Unary minus

    一元减

  2. Bitwise compliment

    按位赞美

  3. Logical Not

    逻辑不

  4. Increment / Decrement

    增量/减量

  5. sizeof() operator

    sizeof()运算符

sizeof() Operator

sizeof()运算符

It is used to return the size of an operand. It can be applied on variable, constant, datatype.

它用于返回操作数的大小。 它可以应用于变量,常量,数据类型。

Syntax:

句法:

sizeof(operand);

Example:

例:

    int a=2, b;
b = sizeof(a);
//or
b = sizeof(int);
//or
b = sizeof(5);
printf("%d\n",b);
//All of the 3 three statements will give same output.

Ternary operators

三元运算符

They are also called conditional operator. For these operators, we require 3 operands for execution. There is only and one ternary operator in C language.

它们也称为条件运算符。 对于这些运算符,我们需要3个操作数来执行。 用C语言只有一个三元运算符。

Syntax:

句法:

 expression_1  ? expression_2 : expression_3 ;

If expression_1 is true expression_2 gets executed, if false then expression_3.

如果expression_1为true,则执行expression_2 ,如果为false,则执行expression_3 。

Example:

例:

    int a=4 , b=7 , c;
c = ( a<7 ? a:b );
printf("%d\n", c );

Output

输出量

 4

Since, a = 4, exp_1 is true and therefore exp_2 gets executed. So, c = a gets executed.

由于a = 4 , exp_1为true,因此exp_2被执行。 因此, c = a被执行。

Binary operators

二元运算符

i) Arithmetic operators

i)算术运算符

Operator name Operator
Addition +
Subtraction -
Multiplication *
Division /
Modulus %
操作员姓名 操作员
加成 +
减法 --
乘法 *
/
模量

Modulus operator gives remainder and division operator gives quotient. All arithmetic operators can be used for integer and float values except modulus which is used for integers only.

模运算符给出余数,除法运算符给出商。 除模数仅用于整数外,所有算术运算符均可用于整数和浮点值。

b) Relational operators

b)关系运算符

They are used for comparison between two values. They return result as true or false.

它们用于两个值之间的比较。 它们返回结果为true或false。

Operator name Operator
Less than <
Less than or equal to <=
Greater than >
Greater than or equal to >=
Equal to ==
Not equal to !=
操作员姓名 操作员
少于 <
小于或等于 <=
比...更棒 >
大于或等于 > =
等于 ==
不等于 !=

c) Logical operators

c)逻辑运算符

Used to combine two relational expression and they returns result as true or false.

用于组合两个关系表达式,它们返回结果为true或false。

A B A && B A || B !A
0 0 0 0 1
0 1 0 1 1
1 0 0 1 0
1 1 1 1 0
一个 A && B A || 乙 !一个
0 0 0 0 1个
0 1个 0 1个 1个
1个 0 0 1个 0
1个 1个 1个 1个 0
.minHeight{ min-height: 250px; } @media (min-width: 1025px){ .minHeight{ min-height: 90px; } } .minHeight{ min-height: 250px; } @media (min-width: 1025px){ .minHeight{ min-height: 90px; } }

d) Bitwise operators

d)按位运算符

They are used to perform operation on individual bits. They can be applied on char and int.

它们用于对单个位执行操作。 它们可以应用于char和int 。

Operators Symbol name Meaning
& Ampersand Bitwise AND
| Pipe Bitwise OR
^ Caret Bitwise X OR
~ Tilde Bitwise compliment
<< Double less than Left shift operator
>> Double greater than Right shift operator
经营者 符号名称 含义
&符 按位与
| 按位或
^ 插入符号 按位X OR
蒂尔德 按位赞美
<< 少于两倍 左移运算符
>> 大于 右移运算符

C Operator Precedence Table:

C运算符优先级表:

This page lists C operators in order of precedence (highest to lowest). Their associativity indicates in what order operators of equal precedence in an expression are applied.

本页按优先顺序(从高到低)列出C运算符。 它们的关联性指示在表达式中应用相同优先级的运算符的顺序。

翻译自: https://www.includehelp.com/c/basics-of-c-language.aspx

c语言语言教程0基础

c语言语言教程0基础_C语言基础相关推荐

  1. C语言 NULL 和 0 区别 - C语言零基础入门教程

    目录 一.关于 NULL 定义 二.NULL 和 0 区别 三.猜你喜欢 零基础 C/C++ 学习路线推荐 : C/C++ 学习目录 >> C 语言基础入门 一.关于 NULL 定义 NU ...

  2. c语言最小点对问题_C语言教程(一):程序开发理论基础!

    前言: 1.本系列教程适用于刚开始学习 C 语言的同学,或者初级开发者,或者想系统详细了解 C 语言的小伙伴. 2.本系列教程会从C语言基础到 C 语言高级语法,包含 C 语言所有系列. C语言简介 ...

  3. c语言prime函数怎么用_C语言教程_v20201106

    编程基础 1.1    通俗地理解什么是编程语言 1.2    C语言究竟是一门怎样的语言? 1.6    初中毕业能学会编程吗? 1.7    C和C++到底有什么关系? 1.8    学了 C 语 ...

  4. c语言教程+school,C语言教程方法用法 _C语言-w3school教程

    C语言 的 C语言教程 此C语言教程与编程方法面向C语言初学者和专业人士,帮助他们轻松了解和学习C语言编程.我们的C语言教程中使用程序解释每个主题. C语言被开发用于创建系统应用程序,直接与硬件设备( ...

  5. c语言string函数的用法_C语言基础| 指针和函数

    点击蓝字关注我们 指针和函数 栈帧:当函数被调用时,系统会在stack空间上申请一块内存,用来给函数提供空间,存储形参和局部变量(定义在函数内部的变量). 当函数调用结束时,这块内存空间会被自动释放( ...

  6. vc 运行c语言步骤,第1章_C语言概述(vc++环境如何运行c语言程序)[精选].ppt

    第1章_C语言概述(vc环境如何运行c语言程序)[精选] C语言程序设计 授课对象:电子商务06 时间安排: 理论课(1-9周): 星期一 5-6节 9407D 星期三 5-6节 9410D 实验课( ...

  7. c语言程序设计教程ppt,《C语言程序设计教程》.ppt

    <<C语言程序设计教程>.ppt>由会员分享,可在线阅读,更多相关<<C语言程序设计教程>.ppt(30页珍藏版)>请在装配图网上搜索. 1.第1章 预 ...

  8. c语言n次方怎么输入_C语言实现斐波拉契数列

    C语言实现斐波拉契数列教程 怎么使用 C 语言实现计算斐波拉契数列的第 N 项的值? C语言实现斐波拉契数列详解 背景知识 斐波那契数列是一组第一位和第二位为 1,从第三位开始,后一位是前两位和的一组 ...

  9. c程序设计语言 qsort,【程序设计基础_C语言】北理工的恶龙(附qsort范例)

    [程序设计基础_C语言]北理工的恶龙(附qsort实例) 北理工的恶龙(附qsort实例) 背景:最近,北理工出现了一只恶龙,它长着很多 头,而且还会吐火,它将会把北理工烧成废墟, 于是,校长下令召集 ...

最新文章

  1. 如何起一个好的学术期刊论文题目?
  2. 哈尔滨金融学院计算机系学生会,哈尔滨金融学院计算机系实习报告(毕业分散实习).doc...
  3. shell awk sed tr grep 语法汇总
  4. 【企业管理】如何让管理有效
  5. 字符串是单一字符的无序组合吗_Python学习笔记(八)组合数据类型
  6. 美团科技 Java工程师_美团Java工程师面试题(2018秋招)
  7. 序列上问题(逆元+整数快速幂)
  8. CASIA WebFace、WIDDER FACE、FDDB、AFLW、CelebA训练集详解
  9. 宁波户外广告调查报告
  10. Virtualbox以及VWare在Win10下的不兼容
  11. Spine(2d动画制作软件)绿色中文最终优化版V3.8.75 | spine动画软件下载
  12. 内网通修改积分文件_【页游逆向】4399小游戏积分系统分析及修改积分
  13. S4 HANA BP 维护客户信贷管理数据
  14. my security / csdn / 2000w / chakaifang.info
  15. 导航栏的HTML的布局方式
  16. 7 Android的VM虚拟机是哪个,Android的VM虚拟机是哪个?
  17. 中国十大悍匪排行榜,屌爆了!!!!
  18. 编写你的应用程序(三)、3D图形
  19. 实践数据湖iceberg 第三十四课 基于数据湖icerberg的流批一体架构-流架构测试
  20. SpringMvc接收请求

热门文章

  1. altium designer 10哪个作者写的好 。
  2. 插入文件找不到桌面了?
  3. html 英文文字纵向排列,CSS几种简单方法实现文字竖向排版
  4. rip协议中周期性广播路由信息的报文_技术实操||距离矢量路由协议-RIP
  5. java定义一个course类,求指教定义一个学生类 ,大学生小学生,定义一个选课接口...
  6. django中间件及中间件实现的登录验证
  7. 设计撑百万并发的数据库架构
  8. C# MVC IOC、依赖注入
  9. VM虚拟机显示不能铺满问题
  10. maven project module 依赖项目创建 ---转