answersLogoWhite

0

More answers
User Avatar

Wiki User

11y ago

Get the greatest of the first two numbers. Then get the greatest of the result and the third number.

result = a > b ? a : b;

result = result > c ? result : c;

This can be combined into a single line, but that would involve too much repetition.

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

Use the following function:

int largest_of_3 (int a, int b, int c) {

if (a>b && a>c)

return a;

else if (b>c)

return b;

else

return c;

}

Of course it would be much easier to implement such a function using a more primitive function, returning the largest of two values:

int largest (int a, int b) {

if (a>b) return a;

else

return b;

}

Given this function, the largest of three function becomes:

int largest_of_3 (int a, int b, int c) { return largest (largest (a, b), c);

}

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program to find greatest of three number using conditional operator in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Program to find the greatest number?

The greatest number is infinity.


How do you find the greatest of three numbers using ternery operator?

Compare the first two numbers with the ternary operator. Store the result in a temporary variable. Compare the temporary variable with the third number, again using the ternary operator.


You want to write a simple without using pointer or array c program which will print greatest number when you give 20 number?

i want to write a simple without using pointer or array c program which will print greatest number when i give 20 number .........How far have you gotten so far?


Adjoint operator of a complex number?

Adjoint operator of a complex number?


when the biconditional statement is separated into a conditional and its converse, which of these cannot be the converse?

If a number is nonzero, then the number is positive.


How do you use the conditional statement of turbo c?

#include<stdio.h> void main() { int a=10,b=15; clrscr(); if(a>b) printf("%d is the large number",a); else printf("%d is the large number",b); getch(); }


What is the operator number in the UK?

The main number for reaching a telephone operator in the UK is 100.


What number can you dial to get operator?

The number of a operator will be 0 or 411.


Program to print the greatest number in unix?

There is no such thing as 'the greatest number'. Here is a program in unix to prove it: echo 'for (i=1; i>=0; i= i*2) print i,"\n";' | bc if you want to actually see the output use it this way: echo 'for (i=1; i>=0; i= i*2) print i,"\n";' | bc | less -S


How many true conditional statements may be written using the following statements n is a rational number n is a integer n is a whole number?

Given that an integer is the same as a whole number, there are four true conditional statements.


Write a program to find greatest of three number using conditional operator in c?

To find greatest of 3 digits in one line #includ<stdio.h> #include<conio.h> void main() { int a,b,c; printf("enter a,b,c:); scanf("d%d%d",&a,&b,&c); printf("greatest no: %d"(a>b)?((a>c)?a:c):((c>b)?c:b)); printf("have a nice day"); getch(); }


Is the following a conjunction disjunction conditional or biconditional A number is odd if and only if it is not even?

The statement is bi-conditional. The "if and only if" should have tipped you off immediately.