Question: #include #include #include using namespace std; int main ( ) { int i = 7 , j = 3 ; float f 1 = 7

#include
#include
#include
using namespace std;
int main()
{
int i =7, j =3;
float f1=7.0, f2=3.0;
char c1='7', c2='3', c3='A';
bool flag = true;
string s1="7", s2="3", s3="A";
cout <<"
*****Properties of a variable*******
";
cout << "Name: i\tType: int\tValue:"<< i <<"\tMemory Location: "
<< &i << endl;
cout <<"
*****A. Integer Type*******
";
cout <<"i+j ="<< i+j << endl;
cout <<"i-j ="<< i-j << endl;
cout <<"i*j ="<< i*j << endl;
cout <<"i/j ="<< i/j << endl;
cout <<"i%j ="<< i%j << endl;
cout <<"
*****B.++ operator*******
";
cout <<"i++="<< i++<< endl;
cout <<"++i ="<<++i << endl;
cout <<"
*****C. Float Type*******
";
cout <<"f1+f2="<< f1+f2<< endl;
cout <<"f1-f2="<< f1-f2<< endl;
cout <<"f1*f2="<< f1*f2<< endl;
cout <<"f1/f2="<< f1/f2<< endl;
cout <<"
*****D. Character Type*******
";
cout << "the integer value of char "<< c1<<"="<< int(c1)<< endl;
cout << "the integer value of char "<< c2<<"="<< int(c2)<< endl;
cout <<"
*****E. String Type*******
";
cout <<"7+3="<< s1+s2<< endl;
cout <<"
*****F. Memory Allocation Type*******
";
cout << "memory allocation for integer type (short): "
<< sizeof(short)<<" bytes
";
cout << "memory allocation for integer type: "
<< sizeof(int)<<" bytes
";
cout << "memory allocation for Unsigned type: "
<< sizeof(unsigned)<<" bytes
";
cout << "memory allocation for long integer type: "
<< sizeof(long int)<<" bytes
";
cout << "memory allocation for long long integer type: "
<< sizeof(long long int)<<" bytes
";
cout << "memory allocation for float type: "
<< sizeof(float)<<" bytes
";
cout << "memory allocation for float type (double): "
<< sizeof(double)<<" bytes
";
cout << "memory allocation for char type: "<< sizeof(char)
<<" bytes
";
cout << "memory allocation for boolean type: "<< sizeof(bool)
<<" bytes
";
cout << "memory allocation for char A: "<< sizeof(c3)
<<" bytes
";
cout << "memory allocation for string A: "<< sizeof(s3)
<<" bytes
";
cout << "memory allocation for A "<< sizeof("A")<<" bytes
";
cout <<"
*****G. Constant Values*******
";
cout <<"*** the actual value depends on the particular system
and library implementation.***"<< endl;
cout << "Minimum value for an object of type int: "<< INT_MIN << endl;
cout << "Maximum value for an object of type int: "<< INT_MAX << endl;
cout << "Maximum value for an object of type unsigned int: "
<< UINT_MAX << endl;
cout << "Minimum value for an object of type long int: "
<< LONG_MIN << endl;
cout << "Maximum value for an object of type long int: "
<< LONG_MAX << endl;
cout << "Maximum value for an object of type unsigned long int: "
<< ULONG_MAX << endl;
cout << "Minimum value for an object of type long long int: "
<< LLONG_MIN << endl;
cout << "Maximum value for an object of type long long int: "
<< LLONG_MAX << endl;
cout << "Maximum value for an object of type unsigned long long int: "
<< ULLONG_MAX << endl;
return 0;
}
1. Why the results are different between int division in part A and float division in part C?
2. Explain the result of the operations in Part B
3. What is the integer value of a character?
4. Is there any correlation between the memory size and the maximum value of an object of
that type? Explain your answer.
5. What is an integer overflow? Give an example.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!