Search
 
SCRIPT & CODE EXAMPLE
 

C

js passing array to function

var names = new Array("Mary", "Tom", "Jack", "Jill");

function disp(arr_names) {
  for (var i = 0; i < arr_names.length; i++) {
    console.log(names[i]);
  }
}
disp(names);
//Mary
//Tom
//Jack
//Jill
Comment

Passing array to methods

class parsingArray
{   
    public static void main(String args[])
    {
        int array[] = {1, 2, 3, 4, 5};
        sum(array);
    }
    public static void sum(int[] array)
    {
        int sum = 0;   
        for (int i = 0; i < array.length; i++)
            sum+=array[i];
        System.out.println("sum of array values : " + sum);
    }
}
Comment

passing an array to a function

/**
* myFunction - receives an array param of 10 int variables
*/

void myFunction(int param[10]) {
   .
   .
   .
}
Comment

pass array to function

// Program to calculate the sum of array elements by passing to a function 

#include <stdio.h>
float calculateSum(float num[]);

int main() {
  float result, num[] = {23.4, 55, 22.6, 3, 40.5, 18};

  // num array is passed to calculateSum()
  result = calculateSum(num); 
  printf("Result = %.2f", result);
  return 0;
}

float calculateSum(float num[]) {
  float sum = 0.0;

  for (int i = 0; i < 6; ++i) {
    sum += num[i];
  }

  return sum;
}
Comment

PREVIOUS NEXT
Code Example
C :: command to perform safe shutdown in unix 
C :: C linked sorted lists 
C :: shortest job first 
C :: WAP to create Database using array of structure & display it in C 
C :: command line coursera 
C :: sscanf and sprintf in c 
C :: c bind str and int 
C :: write a ppm image 
C :: String insertion into another string 
C :: read a string 
C :: Trasmettere variabile float attraverso seriale 
C :: ? : em linguagem C 
C :: c text modifiers 
C :: countoddevenDifference 
C :: transpose of a matrix in c 
C :: c if statement 
C :: how to push node using linked list c 
C :: mongodb delete all documents 
Dart :: navigator.pushandremoveuntil flutter 
Dart :: flutter listtile padding 
Dart :: flutter textfield outlineinputborder 
Dart :: open link with button flutter 
Dart :: image fit flutter 
Dart :: flutter chip delete 
Dart :: dart inset all 
Dart :: flutter reverse list 
Dart :: how to disable switch in flutter 
Dart :: flutter vertical space between containers 
Dart :: dart enum 
Dart :: how to get terminal http request time 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =