问题
与其他编程语言相比,C语言有哪些限制?
解决方案
C语言阻止或禁止了面向对象编程语言的概念,如继承、多态、封装和数据抽象。
C编程语言不会对每行代码进行错误检测,它会在完成整个编码后检查错误。
它不具备命名空间属性。
C编程在数据抽象方面的水平不足,即没有非常大的数据处理能力。
C语言不允许用户通过异常处理功能来检测错误。
C语言不支持构造函数和析构函数的概念。
与其他编程语言相比,它不完全支持解决现实世界的问题。
与其他编程语言相比,它的安全性较低。
基本结构
以下是一个“C”程序的一般结构:
/* documentation section */
preprocessor directives
global declaration
main ( ){
local declaration
executable statements
}
return type function name (argument list){
local declaration
executable statements
}
示例
/* Author : Tutorialspoint
Aim : Program for finding circumference of circle*/
#include<stdio.h>
#include<conio.h>
#define PI 3.1415
main ( ){
float c, r;
clrscr ( );
printf ("enter radius of circle");
scanf ("%f", &r);
c = 2 * PI * r;
printf ("Circumference = %f", c);
getch ( );
}
输出
Enter radius of circle r=4
Circumference of circle c=25.132000