Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
sum of arrays
//gcc 5.4.0 #include <stdio.h> #include <malloc.h> int* funcSum(int a[], int b[]) { //int sum = 10; //we can return a local variable to main //static int sum[] = {0,0}; // we cannot return the array as such as its the address return sum, use static or malloc int *sum = malloc(10*sizeof(int)); for (int i=0; i<2; i++) { sum[i] = a[i] + b[i]; } //printf("sum[%d] = %d\n",0,sum[0]); return sum; } int main(void) { //int a=5,b=7; int a[2] = {1,2}; int b[2] = {1,2}; int *result = funcSum(a,b); //printf("Hello, world!\n"); for (int i=0; i<2; i++) { printf("result[%d] = %d\n",i,result[i]); } return 0; }
run
|
edit
|
history
|
help
0
eliminate_duplicates.c
Primes in binary
2 size mas
problem5 review fundamentos
binary to txt
ptr_to_ptr
Newtons method
Find a Node Sibling Test
array poi
convertletter