[Cpp]
// P23
// Assign the character to the integer variable
# Include <iostream>
Using namespace std;
Int main ()
{
Int I, j;
I = 'a ';
J = 'B ';
Cout <I <"" <j <endl;
Return 0;
}
// P23
// Assign the character to the integer variable
# Include <iostream>
Using namespace std;
Int main ()
{
Int I, j;
I = 'a ';
J = 'B ';
Cout <I <"" <j <endl;
Return 0;
} Running result:
[Cpp]
// P24
// Convert lowercase letters to uppercase letters
# Include <iostream>
Using namespace std;
Int main ()
{
Char c1, c2;
C1 = 'a ';
C2 = 'B ';
C1 = c1-32;
C2 = c2-32;
Cout <c1 <"" <c2 <endl;
Return 0;
}
// P24
// Convert lowercase letters to uppercase letters
# Include <iostream>
Using namespace std;
Int main ()
{
Char c1, c2;
C1 = 'a ';
C2 = 'B ';
C1 = c1-32;
C2 = c2-32;
Cout <c1 <"" <c2 <endl;
Return 0;
}
Running result:
[Cpp]
// P25
// Symbolic constant
# Include <iostream>
Using namespace std;
# Define PRICE 30
Int main ()
{
Int num, total;
Num = 10;
Total = num * PRICE;
Cout <"total =" <total <endl;
Return 0;
}
// P25
// Symbolic constant
# Include <iostream>
Using namespace std;
# Define PRICE 30
Int main ()
{
Int num, total;
Num = 10;
Total = num * PRICE;
Cout <"total =" <total <endl;
Return 0;
}
Running result:
[Cpp]
// P34
// Force type conversion
# Include <iostream>
Using namespace std;
Int main ()
{
Float x;
Int I;
X = 3.6;
I = (int) x;
Cout <"x =" <x <", I =" <I <endl;
Return 0;
}
// P34
// Force type conversion
# Include <iostream>
Using namespace std;
Int main ()
{
Float x;
Int I;
X = 3.6;
I = (int) x;
Cout <"x =" <x <", I =" <I <endl;
Return 0;
}
Running result:
[Cpp]
// P35
// Transmit signed data to unsigned Variables
# Include <iostream>
Using namespace std;
Int main ()
{
Unsigned short;
Short int B =-1;
A = B;
Cout <"a =" <a <endl;
Return 0;
}
// P35
// Transmit signed data to unsigned Variables
# Include <iostream>
Using namespace std;
Int main ()
{
Unsigned short;
Short int B =-1;
A = B;
Cout <"a =" <a <endl;
Return 0;
} Running result: