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...
4. Write a function called mean that will return the average value of an integer array....
4. Write a function called mean that will return the average value of an integer array. The integer array and its length must be passed to the function as parameters. 5.Write a function called max that will return the index of the max value of an integer array. The integer array and its length must be passed to the function as parameters. E.g. array = {1,2,3,4,5,6,7,8,9,0} max = 9 index = 8 6.Write a function called variance that calculates and...
Write an evenTest(n) function that returns True if it is given an even integer and False...
Write an evenTest(n) function that returns True if it is given an even integer and False if it is given an odd number. The rest of your code (outside of the function) should get an integer number from the user, call evenTest(n) to test if the number is even, and then tell the user if the number was even or odd. Name the program even_or_odd.py. Part 2. Salary.py (5 pts) You are offered two options to receive salary: • Option...
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...
a. Write a function sumDigits that takes a positive integer value and returns the total sum...
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 Runs: Enter a positive integer: 1000000 The sum of the digits in the number from 1 to 1000000 is 27000001 Enter a positive...
Write a C++ function to print any given std::array of a given type to the standard...
Write a C++ function to print any given std::array of a given type to the standard output in the form of {element 0, element 1, element 2, ...}. For example given the double array, d_array = {2.1, 3.4, 5.6, 2.9}, you'd print {2.1, 3.4, 5.6, 2.9} to the output upon executing std::cout << d_array; line of code. Your function mus overload << operator.
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 intLog of type Integer -> Integer that returns the exponent of the largest...
Write a function intLog of type Integer -> Integer that returns the exponent of the largest power of 2 less than its integer argument. This needs to be a haskell function
Write a C function to calculate and return the factorial value of any positive integer as...
Write a C function to calculate and return the factorial value of any positive integer as an argument. Then call this function from main() and print the results for the following input values: 2, 3,4, 5, 10, 15 What is the maximum value of an integer for which factorial can be calculated correctly on a machine using your algorithm?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT