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
Part II: Your Rental Company
B_141121_aleatorios
A_141124_arrayMaxMin01
ponyerb orange panther
Stub Program for Problem 2 HW 2
kill
Prime
Multiple If statements v.09
summing long int
Type struct