Search
 
SCRIPT & CODE EXAMPLE
 

CPP

C++ Pass Array to a Function

void myFunction(int myNumbers[5]) {
  for (int i = 0; i < 5; i++) {
    cout << myNumbers[i] << "
";
  }
}

int main() {
  int myNumbers[5] = {10, 20, 30, 40, 50};
  myFunction(myNumbers);
  return 0;
}
Comment

passing array to the function c++

double getAverage(int arr[], int size) {
  int i, sum = 0;       
  double avg;          

   for (i = 0; i < size; ++i) {
      sum += arr[i];
   }
   avg = double(sum) / size;

   return avg;
}
Comment

C++ Syntax for Passing Arrays as Function Parameters

returnType functionName(dataType arrayName[arraySize]) {
    // code
}
Comment

passing array to the function c++

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

passing array to the function c++

//passing array as a pointer.
void myFunction(int *param) {
   .
   .
   .
}
Comment

passing array to the function c++

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

PREVIOUS NEXT
Code Example
Cpp :: how to use run total in C++ 
Cpp :: c++ vector add scalar 
Cpp :: how to modify set C++ 
Cpp :: qt get wireless interface name 
Cpp :: get shape of eigen matrix 
Cpp :: c++ schleife abbrechen 
Cpp :: sort vector from smallest to largest 
Cpp :: sort using comparator anonymous function c++ 
Cpp :: Chef and the Wildcard Matching codechef solution in c++ 
Cpp :: c++ regex to validate indian phone number pattern 
Cpp :: c++ merging algorithm 
Cpp :: float to byte array and back c++ with memcpy command 
Cpp :: c++ comments 
Cpp :: escribir texto c++ 
Cpp :: c ++ loop 
Cpp :: how to merge string array in C++ 
Cpp :: c++ copy with transform 
Cpp :: sro in c++ 
Cpp :: bash script add another user 
Cpp :: private static c++ 
Cpp :: boost filesystem get filename without exetention from path 
Cpp :: arduino jumper programmieren 
Cpp :: racing horses codechef solution c++ 
Cpp :: add nested vector cpp 
Cpp :: lambda - print-out array and add comment 
Cpp :: what is a string called in c++ 
Cpp :: multiply two arbitrary integers a and b (a greater than b) 
Cpp :: how to get the numbers in a vector c++ sfml 
Cpp :: search in vector of pairs c++ 
Cpp :: cpp queue 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =