Question

[C++ Language] Define a function to find the largest element from an integer array.

  1. [C++ Language] Define a function to find the largest element from an integer array.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

function definition to find the largest element from an integer array.
int largest(int arr[] , int n){
   int max = arr[0];
   for(int i=0;i<n;i++){
       if(arr[i] > max) max = arr[i];
   }
   return max;
}

Add a comment
Know the answer?
Add Answer to:
[C++ Language] Define a function to find the largest element from an integer array.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Hey guys I need a c++ function to find the largest element in a 2d array...Please!!!!...

    Hey guys I need a c++ function to find the largest element in a 2d array...Please!!!! Thanks!!!

  • 1. Write a C function named find that receives a one-dimensional array of type integer named...

    1. Write a C function named find that receives a one-dimensional array of type integer named arr and its size of type integer. The function fills the array with values that are the power of four (4^n) where n is the index. After that, the function must select a random index from the array and move the array elements around the element stored in the randomly selected index Example arr = [1, 4, 16, 64, 256) if the randomly selected...

  • B. Which statement would be used to define a to element integer array c? a. Array...

    B. Which statement would be used to define a to element integer array c? a. Array c = int[10]; b. C = int[10]; c. int Array c[10]; d. int c[10]; 17. Declare an Integer pointer variable named int_ptr. 18. Use the pointer created in question 17 and assign it the memory location of a variable named int_var. 19. Suppose you have an executable program named count that counts the characters in its input. Devise a command-line command using the count...

  • in C language Write a program to find the element of an array, which occurs maximum...

    in C language Write a program to find the element of an array, which occurs maximum number of times and its count. The program should accept the array elements as input from the user and print out the most occurring element along with its count. Hint: array size is 5. For example: Enter array elements (array size 5): 22321 Output: Max occurring element: 2. count: 3

  • Please solve this C language progrm (2-D Array program) the most basic way ! Thank You!...

    Please solve this C language progrm (2-D Array program) the most basic way ! Thank You! Write a function that takes a 4 x 4 array of integers as its parameter. The function must use two nested for-loops to determine the largest integer in the array as well as its row and column numbers. Recall that C-functions cannot return multiple values. Use pointers in the function parameter list to relay the results to the caller program. Write another function, which...

  • C++ QUESTION Loops, arrays, functions find the three largest values in an array of integers and...

    C++ QUESTION Loops, arrays, functions find the three largest values in an array of integers and output them to the screen. You must utilize at least three functions, counting main as a function, AND you must use parameters/arguments in one of them. Set up an integer array of 10 elements, read in the ten elements from the keyboard. There are many ways to solve this lab. Here are a couple of ideas: Use a function to find the largest value...

  • Write a program in C++ language that finds the largest number in an array of positive...

    Write a program in C++ language that finds the largest number in an array of positive numbers using recursion. Your program should have a function called array_max that should pass in an int array, and an int for the size of the array, respectively, and should return an int value. As an example, given an array of size 10 with contents: {10, 9, 6, 1, 2, 4, 16, 8, 7, 5} The output should be: The largest number in the...

  • C Programming Language 2(a) Define a struct with 1 int array named i, 1 float array...

    C Programming Language 2(a) Define a struct with 1 int array named i, 1 float array named f, and one double array named d, each of size M. (b)Declare array x with N of those structs. (c)Write a void function to traverse array x (using a pointer) assigning to each element in each array d (in each struct in array x) the sum of the corresponding elements in arrays i and f (in the same struct). Use 3 pointers (of...

  • a) (C language) Let’s consider an integer array of size 10. (10 marks, each part is...

    a) (C language) Let’s consider an integer array of size 10. (10 marks, each part is 2 marks) int a[10]; I. How would you assign a pointer, called pA, to store the address of element 0 of this array? Write the C code for your answer. II. Using pA, how would you obtain the value of the next element (element 1) of the array? III. Explain in 2-3 sentences what the statement pA = a[1]; would do. IV. Is the...

  • Below is a pseudocode for a function that finds the integer 5 in the 3 element integer array. The...

    Below is a pseudocode for a function that finds the integer 5 in the 3 element integer array. The number 5 is in the array, but it is not known where it is. The Find5 function returns it’s seat number. Find5 (A[1..3]) found = false while( not found ) i = random(1, 3) if A[i] == 5 then found = true return i The function random (i, j) returns the integer of the closed range [i..j] with equal probability for...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT