Question

write a c++ function, do not #include anything, that returns the max of 6 ints int...

write a c++ function, do not #include anything, that returns the max of 6 ints

int max(int, int, int, int, int, int);

allowed to use built in max(int, int) function.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

int max(int i1, int i2, int i3, int i4, int i5, int i6)
{
int m = std::max(i1,i2); // m has maximum of i1 and i2
m = std::max(m,i3); // compare m with i3
m = std::max(m,i4); // compare m with i4
m = std::max(m,i5); // compare m with i5
m = std::max(m,i6); // compare m with i6
  
return m; // return maximum
}

Add a comment
Know the answer?
Add Answer to:
write a c++ function, do not #include anything, that returns the max of 6 ints int...
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
  • Using C Write a function that takes two ints and returns the minimum (smallest) of those...

    Using C Write a function that takes two ints and returns the minimum (smallest) of those two ints. Include a function prototype. In main, call the function with two int inputs of your choice and print the returned value to the output window. The function should not print, just return the smallest number (int). If the numbers are the same, the minimum is just the number. Please use notes to explain, thanks!

  • Write a function that takes two ints and returns the average (float) of those two ints....

    Write a function that takes two ints and returns the average (float) of those two ints. Include a function prototype. In main, call the function with two int inputs of your choice and print the returned value to the output window. The function should not print, just make the calculation an return the average. C language not C++

  • Implement the function odd_total (xs) that takes a list of list of ints xs and returns...

    Implement the function odd_total (xs) that takes a list of list of ints xs and returns the sum of the odd numbers but skips the numbers on the first row and the last column of xs. You're not allowed to modify xs. You can't use any built-in function or method except int, str, range and len. Example: odd_total ([[1,2,3],[4,5,6], [7,8,9]]) - - > 12

  • C++ clock.h /* Write a function get_hours that returns an int and accepts an int seconds_since_1970...

    C++ clock.h /* Write a function get_hours that returns an int and accepts an int seconds_since_1970 parameter */ int get_hours(int seconds_since_1970); /* Write a function get_minutes that returns an int and accepts an int seconds_since_1970 parameter */ int get_minutes(int seconds_since_1970); /* Write a function get_seconds that returns an int and accepts an int seconds_since_1970 parameter */ int get_seconds(int seconds_since_1970); clock.cpp #include "clock.h" /* Write get_hours code to return hours given seconds since 1970 int */ /* Write get_minutes code to...

  • help me solving this both please in c++ language 6 Write function max(int al Lint n)...

    help me solving this both please in c++ language 6 Write function max(int al Lint n) that receives an array of integer and its length, it returns the maximum number in that array. Test your function in main. 7) Write functin reverse (char x[ .int n) that reieves an array of characters and reverse the order of its elements. Test this function in main.

  • C programming Write a function that gets a 2-d array of given dimensions of ints. It...

    C programming Write a function that gets a 2-d array of given dimensions of ints. It returns true if the array contains two rows with exactly the same values in the same order, and returns false otherwise, bool contains_equal_rows(int height, int width, const int ar[height] [width]) Examples: On input {{1,2,3,4}, {2,3,4,1}, {1,2,3,4}} it returns true. On input {{1,2,3,4}, {2,3,4,5}, {3,4,5,6}} it returns false. On input {{1,1,1,1}, {2,2,2,2}, {1,1,1,6}} it returns false.

  • Write a short C++ function, isTwoPower, that takes an int i and returns true if and...

    Write a short C++ function, isTwoPower, that takes an int i and returns true if and only if i is a power of 2. Do not use multiplication or division,

  • a) Write a function that takes as input 2 parameters, an array and its size (both...

    a) Write a function that takes as input 2 parameters, an array and its size (both ints) and returns the max. Include the driving (main program also. To pass an array to a function, do the following: return_type my_function(int my_array[], int size) b) Write a function that does the above but can contain duplicate numbers and is capable of removing them. Scan in input. Note you may need the sizeof( ) function which is one of the standard libraries.Thus you...

  • Write a function that takes an int as an argument and returns true if the int...

    Write a function that takes an int as an argument and returns true if the int is an even number and false if not. In any case change the value of the original argument to twice its value. Use the integers 0 through 4 as test cases. Do not use any arrays.

  • Write a function getScores(...) that is given a string, an int type array to fill and...

    Write a function getScores(...) that is given a string, an int type array to fill and the max number of elements in the array as parameters and returns an integer result. The function will find each substring of the given string separated by space characters and place it in the array. The function returns the number of integers extracted. For example: int values[3]; getScores("123 456 789", values, 3 ); would return the count of 3 and fill the array with...

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