← cproj

return void, add pointers in function paramters

41f3b1d064403396487eda96ddc2c56bb964383b · ovidiucs · Dec 2, 2019 17:13

+19 · 1 file changed

  • graph/db/codevault/ret_multiple_values_from_func.c +19 −0
diff --git a/graph/db/codevault/ret_multiple_values_from_func.c b/graph/db/codevault/ret_multiple_values_from_func.c
new file mode 100644
index 0000000..1775061
--- /dev/null
+++ b/graph/db/codevault/ret_multiple_values_from_func.c
@@ -0,0 +1,19 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+void sumAndProduct(int a, int b, int* sum, int* prod){
+  *sum = a + b;
+  *prod = a * b;
+}
+
+
+int main (int argc, char** argv) {
+    int x = 5;
+    int y = 12;
+    int sum = 0
+    int prod = 0;
+    sumAndProduct(x, y, &sum, &prod);
+    fprintf(stdout,"The sum is %d and the product is %d\n", sum, prod);
+
+   return EXIT_SUCCESS;
+}