answersLogoWhite

0


Best Answer

Use the following template function:

template<class T>

T& max(T& x, T& y){return(y<x?x:y;}

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How to write C plus plus Program to take 2 distant values as argument and return the larger value on the screen?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a c program to find the largest and second largest number out of 3 numbers?

// return the larger of any 2 numbers int larger (int a, int b) { return a&gt;b?a:b; } // return the largest of any 3 numbers int largest (int a, int b, int c) { return larger (larger (a, b), c)); } // return the middle value of any 3 numbers int middle (int a, int b, int c) { if (a&gt;b) a^=b^=a^=b; // swap a and b (b is now the larger of the two) if (b&gt;c) b^=c^=b^=c; // swap b and c (c is now the largest of all three) return larger (a, b); // return the larger of a and b }


What does sqrt function return?

square root of the argument


What is functions in c?

A function is a small set of instructions designed to operate on its given input (aka parameters or arguments) and perform some action or return some output. Generally in programming a commonly used strategy is to take a large program and break it into smaller chunks, which are turned into functions. So say that you are writing a large program and constantly have to see which of two numbers is larger, you could write a function: int larger(int a, int b) { if(a &gt; b) return a; else return b; } Now in your program, you can simply say: int x = larger(number1, number2);


Where do you use no argument no return in c function?

Where there is no need to return any type of value from a function


What distant country had Menelaus ended up in trying to return home?

Egypt


What is the duration of Return to Oz TV program?

The duration of Return to Oz - TV program - is 3060.0 seconds.


When was Return to Oz - TV program - created?

Return to Oz - TV program - was created on 1964-02-09.


Sample program in c plus plus with parameter?

C++ doesn't have parameters it has arguments, both formal and actual. Actual arguments are the arguments you pass to a function. Formal arguments are the arguments used by the function and which are treated as local variables within the function body. Formal arguments always fall from scope when the function returns. In order for a function to make changes to the actual argument you you can either return the formal argument by value and assign the function to the actual argument upon return, or you can pass the argument by reference. In the former case, the returned value is temporary. If the function is not assigned to the actual argument, the temporary value falls from scope. In the latter case, the actual and formal arguments both refer to the same object through separate names (aliases). Thus any operations performed on the formal argument will affect the actual argument (they are one and the same object). Example: // Forward declarations. int byval (int); void byref (int&amp;); int main() { int actual = 42; byval (actual); // The byval formal argument is no longer in scope. // Although a temporary value of 84 was returned, // it wasn't assigned to anything and is no longer // available. // The actual argument still has the value 42. actual = byval (actual); // The byval formal argument is no longer in scope, // however, its value was returned and assigned // to the actual argument. // The actual argument now has the value 84. byref (actual); // The formal argument and the actual argument are // one and the same argument. // The actual argument now has the value 42. } int byvalue(int formal) { formal *= 2; return formal; } // The formal argument no longer exists, but its value // was pushed into the function's return address. That // value will cease to exist unless the caller immediately // assigns the function's return value to a variable. void byref(int&amp; formal) { formal /= 2; } // The formal argument no longer exists and nothing // was pushed onto the function's return address. // However, formal was just an alias for the actual // argument, thus the actual argument has already // been updated.


Which point is the memory address of the location in the program that the Computer will return to when a module ends?

return point


How to write C program without operater?

// a complete C program without using any operators int main() { return 0; } // a non-useless program, which accepts a single command line argument and // prints whether or not the first character is a vowel int main(int argc, char** argv) { if(argc != 2) { return 1; } switch(argv[1][0]) { case 'a': case 'e': case 'i': case 'o': case 'u': printf("vowel\n"); break; default: printf("not vowel\n"); } return 0; }


Is spinoffs develop a logical argument to support the functing of NASA's space program?

Yes. Every dollar spent on NASA tends to return at least 7 dollars from tech spinoff. So it is a good investment that pays off well.


Is it weird to contact a distant ex to return her property to her?

It depends what you're trying to return to her. If it is something replacable she probably has already replaced it if she is distant at this point. Unless of course your trying to rebuild some kind of relationship then you should just call her instead of worrying about being weird.