C++, Create a function called larger which takes two integers as its parameters and returns the larger of the two integers
Code:
#include<iostream>
using namespace std;
int larger(int num1,int num2) //larger function which takes two numbers num1,num2 as parameters
{
if (num1>num2) //checking num1 is greater than num2
return num1; //return num1
else
return num2; //in other case return num2
}
int main()
{
int num1,num2;
cout << "Enter the First Number : "; //asking user to enter the number 1
cin >> num1;
cout << "\nEnter the Second Number : "; //asking user to enter the number 2
cin >> num2;
cout << "\nThe larger element among "
<< num1 << " and " << num2 << " is "
<< larger(num1,num2);
//calling larger function with parameters num1,num2
and printing the larger among the numbers returned by the
function.
return 0;
}
Code and Output Screenshots:



Note : if both numbers are equal that means no one is greater than so it will directly print the second number given
For example two numbers are 5 and 5 then the greatest number among them is 5 only since both are equal 5 is the greatest number and 5 is the lowest number.
Note : if you have any queries please post a comment thanks a lot..always available to help you...
C++, Create a function called larger which takes two integers as its parameters and returns the...
Write a Java method called compare that takes two integers as input parameters and returns 1 if the first parameter is larger than the second parameter returns – 1 if the second parameter is larger than the first parameter, and returns 0 if the two parameters are equal.
C++ write a function named subtract that takes two integers as parameters and returns the result of subtracting the second number from the first. i.e. int1 - int2 Change subtract to have default arguments for its two parameters. Pick whatever non-zero numbers you would like. Write a prototype for subtract before main so the program runs without error. I cant figure out the part where you pass no parameters, I've tried to set defailt values for the parameters but it...
Write a C function called min which takes 2 integers as input, and returns the smallest as the result?
python Write a function called has_odd_even that takes three integers as parameters and that returns True if there is at least one odd and at least one even among the three numbers and that returns False otherwise. Below are some sample calls and the appropriate value to return. Function call Value returned has_odd_even(2, 4, 6) False has_odd_even(2, 3, 4) True has_odd_even(12, 4, 17) True has_odd_even(5, 17, 4) True has_odd_even(14, 7, 5) True has_odd_even(5, 4, 2) True has_odd_even(13, 20, 91) True...
Write a function in the C++called summary that takes as its parameters an input and output file. The function should read two integers find the sum of even numbers, the sum of odd numbers, and the cumulative product between two values lower and upper. The function should return the sum of even, odd, ad cumulative product between the lower and upper values. Please write program in C++.
Python
1 Write a function called sum_odd that takes two parameters, then calculates and returns the sum of the odd numbers between the two given integers. The sum should include the two given integers, if they are odd. You can assume the arguments will always be positive integers, and the first smaller than or equal to the second. 3 To get full credit on this problem, you must define at least 1 function, use at least 1 loop, and use...
Write a recursive function named multiply that takes two positive integers as parameters and returns the product of those two numbers (the result from multiplying them together). Your program should not use multiplication - it should find the result by using only addition. To get your thinking on the right track: 7 * 4 = 7 + (7 * 3) 7 * 3 = 7 + (7 * 2) 7 * 2 = 7 + (7 * 1) 7 *...
Can you write a function that takes 2 vectors as parameters and returns a larger vector containing the two vectors Example Vector a: 1 2 3 4 5 Vector b: 6 7 8 9 10 Concatenated vector: 1 2 3 4 5 6 7 8 9 10
Create a function that takes two parameters : pointer to the array and the size of the array. Print out the array's values and their memory addresses inside the function. Then create another function that takes two parameters : pointer to the array. Inside the function, multiply each of the array's values by two ad print the modified values out in the main function. With C programming language
Write a C++ function, smallestIndex, that takes as parameters an
int array and its size and returns the index of the first
occurrence of the smallest element in the array. To test your
function, write a main that prompts a user for a list of 15
integers and outputs the index and value of the first occurrence of
the smallest value.
The program should print out
Enter 15 integers:
The position of the first occurrence of the smallest element in...