1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
real x=3.14,y;
int i,j;
complex c;
cout << " x = " << x << "\n";
x = 1;y=2;
x=y;
i=0;j=1;
cout << 1 + 3 << " " << 1/3 << "\n";
cout << 10 ^10 << "\n";
cout << 10 ^-10 << "\n";
cout << -10^-2+5 << "== 4.99 \n";
cout << 10^-2+5 << "== 5.01 \n";
cout << "------------------ complex ---- \n" ;
cout << 10-10i << " \n";
int prec=cout.precision(12);
cout.scientific << " scientific : \n";
cout << " -1^(1/3) = " << (-1+0i)^(1./3.) << " (precision=12)\n";
cout.precision(prec);
cout.fixed;
cout.showpos << " fixed and showpos :\n";
cout << " -1^(1/3) = " << (-1+0i)^(1./3.) << " (precision="<<prec << ")\n";
cout.noshowpos << "noshowpos\n";
cout << " 8^(1/3)= " << (8)^(1./3.) << " \n";
cout << " sqrt(-1) = " << sqrt(-1+0i) << " \n";
complex a=10+1i;
cout.default << "default \n";
cout << a << endl;
cout << " real(a) = " <<real(a) << " conj(a)" << conj(a)
<< " arg(a) = " << arg(a) << endl;
cout << " ++i =" << ++i ;
cout << " i=" << i << "\n";
cout << " i++ = "<< i++ << "\n";
cout << " i = " << i << "\n";
// ---- string concatenation ----------
string str,str1;
str="abc+";
str1="+abcddddd+";
str=str + str1;
str = str + 2 ;
cout << "str= " << str << "== abc++abcddddd+2;\n";
{ real x=0;
for (int i=0;i<10;i++)
x += i*i;
cout << " x= " << x << endl;
// example of if arithmetic expression
real a = x == 0 ? x : -1;
real b = x != 0 ? x : -1;
cout << " a = " << a << " b = " << b << endl;
string ss="\z\a\b\f\\--\\";
cout << "\""<< ss << "\"" << endl;
}
|