summaryrefslogtreecommitdiffhomepage
path: root/c.html.markdown
diff options
context:
space:
mode:
Diffstat (limited to 'c.html.markdown')
-rw-r--r--c.html.markdown17
1 files changed, 16 insertions, 1 deletions
diff --git a/c.html.markdown b/c.html.markdown
index db2ac930..b99cfe84 100644
--- a/c.html.markdown
+++ b/c.html.markdown
@@ -472,7 +472,22 @@ char c[] = "This is a test.";
str_reverse(c);
printf("%s\n", c); // => ".tset a si sihT"
*/
-
+//as we can return return only one variable
+//to change values of more than one variables we use call by reference
+void swapTwoNumbers(int *a, int *b)
+{
+int temp = *a;
+*a = *b;
+*b = temp;
+}
+/*
+int first = 10;
+int second = 20;
+printf("first: %d\nsecond: %d\n", first, second);
+swapTwoNumbers(&first, &second);
+printf("first: %d\nsecond: %d\n", first, second);
+// values will be swapped
+*/
// if referring to external variables outside function, must use extern keyword.
int i = 0;
void testFunc() {