// 123.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> using namespace std; int main() { cout<<"number of bytes in int is:"<<sizeof(int)<<endl; cout<<"number of bytes in long int is:"<<sizeof(long)<<endl; cout<<"number of bytes in short int is:"<<sizeof(short)<<endl; return 0; }
// 123.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> using namespace std; int main() { bool flag=true; cout<<flag<<endl; cout<<boolalpha<<flag<<endl; cout<<flag+5<<endl; flag=0; cout<<"执行语句flag=0;后flag的值为:"<<boolalpha<<flag<<endl; flag=0.0; cout<<"执行语句flag=0.0;后flag的值为:"<<boolalpha<<flag<<endl; return 0; }
// 123.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> using namespace std; int main() { int a,b,c,d; a=4; b=a; a=5; c=d=6; c*=a; d%=a+b; cout<<"a="<<a<<endl <<"b="<<b<<endl <<"c="<<c<<endl <<"d="<<d<<endl; return 0; }
// 123.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> using namespace std; int main() { short i,j,m,n; i=1000; j=1000; m=i+j; n=i*j; cout<<"m="<<m<<endl; cout<<"n="<<n<<endl; return 0; }
// 123.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> using namespace std; int main() { int i=6,j,k,temp; j=++i; k=i++; ++i=1; cout<<"i="<<i<<endl <<"j="<<j<<endl <<"k="<<k<<endl; return 0; }
// 123.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> using namespace std; int main() { char ch; cout << "Please input a character:"; cin >> ch; ch= ch >= 'a'&&ch<='z'?ch-'a'+'A':ch; cout << "The result is :"<< ch << endl; ch= ch >='A' &&ch<='Z'?ch+'a'-'A':ch; cout << "The result is :"<< ch << endl; return 0; }
// 123.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> using namespace std; int main() { int ab,ac; double b = 3.14; char c = 'A',ad; ab = int(b); ac = int(c); ad = char(int(b)); cout << "b = "<<b<<endl; cout << "ab = "<<ab<<endl; cout << "c = "<< c << endl; cout << "ac = " << ac <<endl; cout << "ad = " << ad << endl; return 0; }