中英双语C语言介绍
Posted CodeAllen2022
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了中英双语C语言介绍相关的知识,希望对你有一定的参考价值。
这是双语编程学习 - 「C语言篇」的第「1」篇文章,感谢关注,点赞,转发!
原文链接:【中英双语】C语言介绍
C is a procedural programming language. It was initially developed by Dennis Ritchie in the year 1972. It was mainly developed as a system programming language to write an operating system. The main features of the C language include low-level memory access, a simple set of keywords, and a clean style, these features make C language suitable for system programmings like an operating system or compiler development.
C是一种面向过程编程语言。它最初由Dennis Ritchie在1972年开发。它主要是作为编写操作系统的系统编程语言开发的。C语言的主要功能包括访问底层内存,一组简单的关键字和干净的样式,这些功能使C语言适用于操作系统或编译器开发等系统编程。
Many later languages have borrowed syntax/features directly or indirectly from the C language. Like syntax of Java, php, javascript, and many other languages are mainly based on the C language. C++ is nearly a superset of C language (Few programs may compile in C, but not in C++).
许多后来的语言直接或间接地从C语言中借用了语法/功能。像Java,PHP,JavaScript的语法一样和许多其他语言主要是基于C语言。C++几乎是C语言的超集(很少有程序可以用C语言编译,但不能用C++编译)。
1.Structure of a C program
1.C程序的结构
After the above discussion, we can formally assess the structure of a C program. By structure, it is meant that any program can be written in this structure only. Writing a C program in any other structure will hence lead to a Compilation Error.
经过上述讨论,我们可以正式评估C代码的结构。通过标准结构,这意味着任何程序只能在此结构中编写。因此,在任何其他结构中编写C程序都会导致编译错误。
The structure of a C program is as follows:
C 程序的结构如下:
The components of the above structure are:
上述结构的组成部分是:
1.Header Files Inclusion: The first and foremost component is the inclusion of the Header files in a C program.
1.头文件包含:第一个也是最重要的在C程序中的组件是包含头文件。
A header file is a file with extension .h which contains C function declarations and macro definitions to be shared between several source files.
头文件是扩展名为 .h 的文件,其中包含要在多个源文件之间共享的 C 函数声明和宏定义。
Some of C Header files:
-
stddef.h – Defines several useful types and macros.
-
stdint.h – Defines exact width integer types.
-
stdio.h – Defines core input and output functions
-
stdlib.h – Defines numeric conversion functions, pseudo-random network generator, memory allocation
-
string.h – Defines string handling functions
-
math.h – Defines common mathematical functions
2.Main Method Declaration: The next part of a C program is to declare the main() function. The syntax to declare the main function is:
2.Main方法声明:C程序的下一部分是声明main()函数。声明 main 函数的语法为:
Syntax to Declare the main method:
1int main()
2
3.Variable Declaration: The next part of any C program is the variable declaration. It refers to the variables that are to be used in the function. Please note that in the C program, no variable can be used without being declared. Also in a C program, the variables are to be declared before any operation in the function.
3.变量声明:任何 C 程序的下一部分是变量声明。它引用要在函数中使用的变量。请注意,在 C 程序中,任何变量都不能在未声明的情况下使用。同样在 C 程序中,变量将在函数中的任何操作之前声明。
Example:
1int main()
2
3 int a;
4.
5.
4.Body: The body of a function in the C program, refers to the operations that are performed in the functions. It can be anything like manipulations, searching, sorting, printing, etc.
4.正文:C程序中某一个函数的主体,是指在函数中执行的运算。它可以是任何类似操作,搜索,排序,打印等。
Example:
1int main()
2
3 int a;
4
5 printf("%d", a);
6.
7.
5.Return Statement: The last part of any C program is the return statement. The return statement refers to the returning of the values from a function. This return statement and return value depend upon the return type of the function. For example, if the return type is void, then there will be no return statement. In any other case, there will be a return statement and the return value will be of the type of the specified return type.
返回语句:任何 C 程序的最后一部分是返回语句。return 语句引用从函数返回值。此返回语句和返回值取决于函数的返回类型。例如,如果返回类型为 void,则不会有 return 语句。在任何其他情况下,将出现一个 return 语句,并且返回值将属于指定返回类型的类型。
Example:
1int main()
2
3 int a;
4
5 printf("%d", a);
6
7 return 0;
8
END
扫描下方二维码
添加好友,备注【英语】
可私聊交流,也可进资源丰富学习群
原文链接:【中英双语】C语言介绍
开发者涨薪指南 48位大咖的思考法则、工作方式、逻辑体系以上是关于中英双语C语言介绍的主要内容,如果未能解决你的问题,请参考以下文章