Question
#include using namespace s t d ; main ( ) { struct f o o t { int x [ 1 0 0 ] ;
#include using namespace s t d ;
main ( ) {
struct f o o t { int x [ 1 0 0 ] ; int va r 1 ; int y [ 1 0 ] ; } f o o ; int va r 2 ; long i ; int p , q ; short int s ; long int l ; struct f o o t bar [ 5 0 ] ;
for ( i =0; i <100; i++) f o o . x [ i ]=100+ i ;
for ( i =0; i <10; i++) f o o . y [ i ]=200+ i ;
f o o . va r 1 = 2 5 0; cout << s i z e o f ( s ) << ;
cout << s i z e o f (p ) << ;
cout << s i z e o f ( l ) << ; q = ( int ) &f o o ;
cout << q << ; p=&( f o o . x [ 5 ] ) ;
cout << p << ; // POINT 1 q = ( int ) &va r 2 ;
cout << q << ; q = p+16;
cout << q << ;
i = ( (long ) p ) + 1 6; q = ( int ) i ; cout << q << ;
s = ( short ) i ; cout << s << ;
l = (long ) i ;
cout << l << ; q = p+95;
cout << q << ; q = p+98;
cout << q << ;
i = ( (long ) p ) + 1 7; q = ( int ) i ;
cout << q << ; q = p + ;
cout << q << ; q = ( int ) ( ( ( long ) p ) + ) ;
cout << q << ; p = ( int ) bar ; ( p + ) = 5 0 0;
cout << bar [ 8 ] . va r 1 << ; }
Run the above program, commenting out the lines with blanks (you may need to modify the header for your system). What output to get? Make sure to mention which computer/compiler you are using. You will need to understand your output befor proceeding to the rest of the homework.
2. Based on the programs output, determine how many bits your system uses to store short, regular, and long integers. The answer may differ depending on your compiler and processor. 3.
3. You wish to determine how many bits your system uses to store pointers. Modify the program to determine this (label your modification MOD in comments), and state your conclusions. 4.
4. Based on your output, make a diagram indicating the addresses in memory where each of the programs variables are stored and their values at POINT 1.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started