Commit 61630b94 authored by elijah vasquez's avatar elijah vasquez 🦍

commit

parent c403ce5a
No preview for this file type
......@@ -6,11 +6,15 @@ int main(void) {
int integer1=1;
short short2=2;
int integer3=3;
char char1=4;
float float1=3.14;
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);
printf("char1 = %d Memory address%p\n", char1, &char1);
printf("float1 = %d Memory address%p\n", float1, &float1);
// Exercise Tasks
// 1 Run this code and take note of the addresses. Run it again and compare the addresses.
......@@ -18,6 +22,7 @@ printf("integer3 =%d Memory address%p\n",integer3,&integer3);
// 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
......@@ -25,8 +30,11 @@ printf("integer3 =%d Memory address%p\n",integer3,&integer3);
// 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
......
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