answersLogoWhite

0

Use the max() template function in the standard library.

#include<iostream>

int main()

{

int x=0, y=1;

int z=std::max(x, y); // z=1

return(0);

}

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

How do you find a largest algorithm in c plus plus?

#define max (a, b) ((a) &gt;= (b)) ? (a) : (b)


C plus plus most accurate and largest range number variable?

double (or, on some platforms, long double)


Write a c plus plus program to find the largest among three numbers using ternary operators?

R = (A &gt; B &amp;&amp; A &gt; C) ? A : (B &gt; C) ? B : C; // parentheses not necessary - for clarity only


How do you find the smallest largest numbers in c language?

for the largest number: #include&lt;stdio.h&gt; void main() { int a,b,c,number,largestnumber; a=99; b=9; c=77; if(a&gt;b) { number=a; } else if(b&gt;c) { number=b; } else { number=c; } largestnumber=number; printf("%d",largestnumber); }


Write a c plus plus program to find largest among three number using control statement and ternary operators?

int max (int a, int b) { return a&lt;b?b:a; } int max3 (int a, int b, int c) { return max (max (a, b), c); }


To find biggest of three number?

Let the numbers be A,B and C and assume that A &ne; B &ne; C 1) Subtract B from A. If the result is a positive number then A &gt; B otherwise B &gt; A. 2) Subtract the greater of A and B from C. If the result is a positive number then C is the largest number otherwise the subtrahend (either A or B) is the largest number.


A plus b plus c equals d. A is the largest answer b is the smallest answer and d is less than 6?

A plus b plus c equals d. A is the largest answer b is the smallest answer and d is less than 6?''


To find biggest of four numbers using if else loop?

largest number a,b,c,d


What are the three variable types largest to smallest in C plus plus?

doginert jesret


Write an algorithm to find the largest number amongst three numbers and draw a flowchart?

Step1- Read a,b,c. Step2-if a&gt;b continue step 5. Step3- b&gt;c then print “b is the largest &quot; and continue step 7. Step4- continue step 6 Step5-if a&gt;c then print “a is the largest &quot; then continue step7. Step6- print “z is largest&quot;. Step7- end.


-8c plus 1 equals -3 what is c?

-8c+1 = -3 -8c = -3-1 -8c = -4 Divide both sides by -8 in order to find the value of c remembering that a minus number divided into minus number is equal to a plus number: c = 1/2


How do you write a program in C plus plus to find the largest of 10 numbers?

#include&lt;iostream.h&gt; #include&lt;conio.h&gt; int main() { int a[10],j; cout&lt;&lt;"Enter 10 numbers."&lt;&lt;endl; for(int i=0;i&lt;=9;i++) cin&gt;&gt;a[i]; j=a[0]; for(i=0i&lt;=9;i++) { if(j&lt;a[i]) j=a[i]; } cout&lt;&lt;"Largest number is "&lt;&lt;j&lt;&lt;endl; return 0; }