return void, add pointers in function paramters
+19 · 1 file changed
-
graph/db/codevault/ret_multiple_values_from_func.c+19 −0
@@ -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; +}