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);
}
#define max (a, b) ((a) >= (b)) ? (a) : (b)
double (or, on some platforms, long double)
R = (A > B && A > C) ? A : (B > C) ? B : C; // parentheses not necessary - for clarity only
for the largest number: #include<stdio.h> void main() { int a,b,c,number,largestnumber; a=99; b=9; c=77; if(a>b) { number=a; } else if(b>c) { number=b; } else { number=c; } largestnumber=number; printf("%d",largestnumber); }
int max (int a, int b) { return a<b?b:a; } int max3 (int a, int b, int c) { return max (max (a, b), c); }
Let the numbers be A,B and C and assume that A ≠ B ≠ C 1) Subtract B from A. If the result is a positive number then A > B otherwise B > 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.
largest number a,b,c,d
A plus b plus c equals d. A is the largest answer b is the smallest answer and d is less than 6?''
doginert jesret
Step1- Read a,b,c. Step2-if a>b continue step 5. Step3- b>c then print “b is the largest " and continue step 7. Step4- continue step 6 Step5-if a>c then print “a is the largest " then continue step7. Step6- print “z is largest". Step7- end.
-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
any number