C++ Premier Plus丨笔记丨第三章

#include<iostream>
using namespace std;
int main(){
	//负数
	int test = -1;
	cout<<test<<endl;
	//sizeof
	cout<<"size of int is "<<sizeof(test)<<endl;
	//MAX and MIN
	cout<<"INT_MAX = "<<INT_MAX<<endl;//符号常量 可以查询各个类型的最大最小值
	cout<<"INT_MIN = "<<INT_MIN<<endl;
	cout<<"CHAR_MAX = "<<CHAR_MAX<<endl;
	cout<<"CHAR_MIN = "<<CHAR_MIN<<endl;
	//不会为负的数
	unsigned int positive = 0;
	positive = -1;
	cout<<"define a unsigned int and assign it as -1, it will be "<<positive<<endl;
	//浮点数
	cout<<"direct cout 10/3 = "<<10/3<<endl;
	float f = 10/3;//float 可表示数据中的前六个或七个有效位
	cout<<"float cout 10/3 = "<<f<<endl;
	double d = 10/3;
	cout<<"double cout 10/3 = "<<d<<endl;
	cout<<"direct cout 10.0/3.0 = "<<10.0/3.0<<endl;
	f = 10.0/3.0;
	cout<<"float cout 10.0/3.0 = "<<f<<endl;
	d = 10.0/3.0;
	cout<<"double cout 10.0/3.0 = "<<d<<endl;
	cout<<"direct cout 10/3.0 = "<<10/3.0<<endl;
	cout<<"direct cout 10.0/3 = "<<10.0/3<<endl;
	cout<<"(float)10/(float)3 = "<<(float)10/(float)3<<endl;
	//算术运算
	cout<<"25/13 = "<<25/13<<endl;//小数部分被丢弃,而非四舍五入
	cout<<"25.0/13.0 = "<<25.0/13.0<<endl;
	
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值