Commit c403ce5a authored by elijah vasquez's avatar elijah vasquez 🦍

commit

parents
File added
#include <stdio.h>
#include <stdalign.h>
int main(void) {
int integer1=1;
short short2=2;
int integer3=3;
printf("integer1 =%d Memory address%p\n",integer1,&integer1);
printf("short2 =%d Memory address%p\n",short2,&short2);
printf("integer3 =%d Memory address%p\n",integer3,&integer3);
// Exercise Tasks
// 1 Run this code and take note of the addresses. Run it again and compare the addresses.
// integer1 =1 Memory address0x7ffc617a86d0
// short2 =2 Memory address0x7ffc617a86ce
// integer3 =3 Memory address0x7ffc617a86d4
// Why might they be different each time you run the code?
// integer1 =1 Memory address0x7ffeb7370260
// short2 =2 Memory address0x7ffeb737025e
// integer3 =3 Memory address0x7ffeb7370264
// 2 Add a char and a float variable, print out the value and address as above
// 3 Extend each printf to also print out the size of each variable type.
// 4 Rearrange the variable declaration order and see if it has an effect on the addresses
// You may want to rearrange your printfs to match the order of your declarations
return 0;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment