阐述C语言的重要性及其总体结构
C语言是一种通用的、过程式的、命令式的计算机编程语言。
C语言的重要性
C语言被称为一种强大的语言,它拥有许多内置函数和操作,可以用来编写任何复杂的程序。
通常,我们将C语言称为中级语言。因为C编译器结合了汇编语言的功能和高级语言的特性。因此,它最适合编写系统软件和业务软件包。
C程序高效且快速。
C语言具有很高的可移植性,也就是说,在一台计算机上编写的C程序可以在另一台计算机上运行,只需很少(或没有)修改。
C语言最适合结构化编程,用户可以将问题分解成函数模块(或)块。
它具有自我扩展的能力。
它被称为“C”,因为它是由BCPL(Basic Combined Programming Language,基本组合编程语言)衍生而来,BCPL俗称“B”语言。
C程序的一般形式
C程序的一般形式如下:
/* documentation section */
preprocessor directives
global declaration
main ( ){
local declaration
executable statements
}
returntype function name (argument list){
local declaration
executable statements
}示例
以下是用无参数且有返回值的函数执行加法的C程序:
#include<stdio.h>
void main(){
//Syntax for addition (function has int because we are returning values for function//
int sum();
int add;
add = sum();
printf("Addition of two numbers is : %d",add);
}
int sum(){
//Declaring actual parameters//
int a,b,add;
//Reading User I/p//
printf("Enter a,b :");
scanf("%d,%d",&a,&b);
//Addition operation//
add=a+b;
//Returning value//
return add;
}输出
执行上述程序后,将产生以下结果:
Enter a,b :4,6 Addition of two numbers is : 10
广告
数据结构
网络
关系数据库管理系统 (RDBMS)
操作系统
Java
iOS
HTML
CSS
Android
Python
C语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP