赋值形式:
C:
int a; a=12;或者 int a=12;
C++:int a; a=12;或者 int a=12;或者 int a(12);
符号常量::
C: define PI=3.1415;
C++: const float PI=3.1415;
float const PI=3.1415;
常量与变量程序示例:
#include<iostream>
using namespace std;
int main(){
const int PRICE=30;
int num,total;
float v,r,h;
num=10;
total=num*PRICE;
cout<<"total:"<<total<<endl;
r=2.5;
h=3.2;
v=r*r*3.14*h;
cout<<"v:"<<v<<endl;
}
这是相应的结果:
编辑C或者是C++的时候,很早以前我是在相应的集成工具里编辑的,现在呢,我不想把电脑里安装太多的集成工具,我已经安装了编辑Java的Eclipse还有
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。