Question

In: Computer Science

Write a function maxFun() that returns the maximum value in any given integer array. Determine the...

Write a function maxFun() that returns the maximum value in any given integer array. Determine the function parameters (complete the area shown in ___________.


___________maxFun(____________________________) {






}

Solutions

Expert Solution

Answer:

Code:

#include<stdio.h>
int maxFun(int a[],int size);//function prototype
//Main function begins here.
int main()
{
   int s=0;
   printf("Enter the size of the array:");
   scanf("%d",&s);
   int array[s];
   for(int i=0;i<s;i++)
   {
       printf("Enter the element number %d: ",i+1);
       scanf("%d",&array[i]);
   }
   int x=maxFun(array,s);
   printf("Here the maximum element : %d",x);
}
// maxFind Function begins here
int maxFun(int a[],int size)
{
   int max=a[0];
   for(int i=0;i<size;i++)
   {
       if(a[i]>max)
       {
           max=a[i];
       }
   }
   return max;
}

Indentation:

Output:


Related Solutions

write the method “getMaxValue” that finds and returns the maximum value in an integer linked list....
write the method “getMaxValue” that finds and returns the maximum value in an integer linked list. If the list is empty, then it should return 0. use the provided code below public class Question03 { public class ListNode//public for testing purposes { public int data;//public for testing purposes public ListNode link;//public for testing purposes public ListNode(int aData, ListNode aLink) { data = aData; link = aLink; } } public ListNode head;//public for testing purposes public int getMaxValue() { //----------------------------------------------------------------------------------- //Write...
Write a function called draw_card. It takes no arguments and returns an integer representing the value...
Write a function called draw_card. It takes no arguments and returns an integer representing the value of a blackjack card drawn from a deck. Get a random integer in the range 1 to 13, inclusive. If the integer is a 1, print "Ace is drawn" and return 1. If the integer is between 2 and 10, call it x, print "<x> is drawn" and return x (print the number, not the string literal "<x>"). If the number is 11, 12,...
python exercise: a. Write a function sumDigits that takes a positive integer value and returns the...
python exercise: a. Write a function sumDigits that takes a positive integer value and returns the total sum of the digits in the integers from 1 to that number inclusive. b. Write a program to input an integer n and call the above function in part a if n is positive, else give ‘Value must be Positive’ message. sample: Enter a positive integer: 1000000 The sum of the digits in the number from 1 to 1000000 is 27000001 Enter a...
Write a C function that finds and displays the maximum value ina two-dimensional array of...
Write a C function that finds and displays the maximum value in a two-dimensional array of integers. The array should be declared as a 10-row-by-20-column array of integers in main (), and the starting the address of the array should be passed to the function. Modify the function so that it also displays the rows and columns number of the element with the maximum value
Write a function convert_date that takes an integer as a parameter and returns three integer values...
Write a function convert_date that takes an integer as a parameter and returns three integer values representing the input converted into days, month and year (see the function docstring). Write a program named t03.py that tests the function by asking the user to enter a number and displaying the output day, month and year. Save the function in a PyDev library module named functions.py A sample run for t03.py: Enter a date in the format MMDDYYYY: 05272017 The output will...
Write a java script function that accepts integer array as input, and display a new array...
Write a java script function that accepts integer array as input, and display a new array by performing fol lowing modifications, • The values in odd index positions must be incremented by 1 • The values in even index positions must be decremented by 1. • Assume the array index starts from 0. Input 1: arr = [1,2,3,4] Output 1: arr = [0,3,2,5 it done html and javascript and plz do it in simple way
Software Decode: Write a function that accepts an in-order array of unsigned integer values. The function...
Software Decode: Write a function that accepts an in-order array of unsigned integer values. The function shall then scan the array for a specific pattern: Three values contained within the array equally spaced 20 units apart. The function shall return the index position within the original array where the pattern begins or -1 if not present. Given the input array: data[] = {10,20,31,40,55,60,65525} The function shall return: 1 IN JAVA PLEASE
Write a c program Write a function to swap two elements of an integer array. Call...
Write a c program Write a function to swap two elements of an integer array. Call the function to swap the first element, i[0] with last element i[n], second element i[1] with the last but one element i[n-1] and so on. Should handle arrays with even and odd number of elements. Call the swap function with the following arrays and print results in each case before and after swapping. i. int arr1[] = {0, 1, 2, 3, 30, 20, 10,...
Using C++ Write a template function that accepts an integer parameter and returns its integer square...
Using C++ Write a template function that accepts an integer parameter and returns its integer square root. The function should return -1, if the argument passed is not integer. Demonstrate the function with a suitable driver program .
Sort a string array by frequency given an array of string write a function that will...
Sort a string array by frequency given an array of string write a function that will return an array that is sorted by frequency example {"hello","hola","hello","hello","ciao","hola","hola","hola"} returned array should be {"hola","hello","ciao"}
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT