Q:

write a c++ program to declare an array and pass it to a void-type function findMax(array) that prints out the maximum value in the array

0

write a c++ program to declare an array A={3,-7, 12, -4 ,5, -2} and pass it to a void-type function findMax(array) that prints out the maximum value in the array

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include<iostream>
using namespace std;

int main()
{
    void findMax(int arr[]);
    
    int A[]={3,-7,12,-4,5,-2};
    findMax(A);
    return 0;
}

void findMax(int arr[])
{
  int max=arr[0];
  for(int i=0;i<6;i++)
  {
      if(arr[i]>max)
      max=arr[i];
  }
  cout<<"largest value in array is "<<max;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now