summary refs log tree commit diff stats
path: root/assignments/24-value-vs-ref.c
diff options
context:
space:
mode:
Diffstat (limited to 'assignments/24-value-vs-ref.c')
-rw-r--r--assignments/24-value-vs-ref.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/assignments/24-value-vs-ref.c b/assignments/24-value-vs-ref.c
index 8640792..094db82 100644
--- a/assignments/24-value-vs-ref.c
+++ b/assignments/24-value-vs-ref.c
@@ -16,6 +16,23 @@ void swap_by_ref(int *a, int *b)
 
 int main(void)
 {
+	int x, y;
+	printf("Enter two numbers: ");
+	scanf("%d%d", &x, &y);
+	printf("The values are: %d %d\n", x, y);
+	swap_by_value(x, y);
+	printf("The values are: %d %d\n", x, y);
+	swap_by_ref(&x, &y);
+	printf("The values are: %d %d\n", x, y);
 	return 0;
 }
 
+/*
+Output:
+Enter two numbers: 2 3
+The values are: 2 3
+The values are: 2 3
+The values are: 3 2
+
+*/
+