-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc3ac2e
commit bdd5443
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
1. Execute the code in "test.c" by hand, and write the output | ||
printed to the terminal into a file called "answer.txt" | ||
|
||
2. Create a Makefile to compile test.c into a program called "test" | ||
|
||
3. Run test and use its output to check your work. | ||
|
||
4. Submit your Makefile and your answer.txt file | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
int f(int ** r, int ** s) { | ||
int temp = ** r; | ||
int temp2 = **s; | ||
int * z = *r; | ||
*r = *s; | ||
*s = z; | ||
printf("**r = %d\n",**r); | ||
printf("**s = %d\n",**s); | ||
*z += 3; | ||
**s -= 8; | ||
**r -= 19; | ||
return temp + temp2; | ||
} | ||
|
||
int main(void) { | ||
int a = 80; | ||
int b = 12; | ||
int * p = &a; | ||
int * q = &b; | ||
int x = f(&p, &q); | ||
printf("x = %d\n", x); | ||
printf("*p = %d\n", *p); | ||
printf("*q = %d\n", *q); | ||
printf("a = %d\n", a); | ||
printf("b = %d\n", b); | ||
return EXIT_SUCCESS; | ||
} |