write an algorithm to check the greatest number among three numbers
Answers
Answer:
Step 1 : Start the program .
Step 2 : Declare variable a, b, c, largestValue.
Step 3 : If a > b go to step 4 Otherwise go to step 5
Step 4. If a > c SET largestValue = a Otherwise largestValue = c
Step 5 : If b > c SET largestValue = b Otherwise largestValue = c
Step 6 : End.
package conditionalStatements;
import java.util.Scanner;
public class LargestValue{
Public static void main(String [] args){
Scanner sc = new Scanner(System.in);
int a,b,c,largestValue;
System.out.print("a = ");
a = sc.nextInt();
System.out.print("b = ");
b = sc.nextInt();
System.out.print("c = ");
c = sc.nextInt();
if(a>b){
if(a>c){
largestValue = a;
}else{
largestValue = c;
}
}else{
if(b>c){
largestValue = b;
}else{
largestValue = c;
}
}
System.out.println("Largest among three numbers is = "+largestValue);
}
}
Explanation:
if you are pleased with answer in turn
please subscribe my youtube chanel(Ramakrishna Nallangari youtube channel) for my effort
search for nallangari in google and find ramakrishna nallnagari and then click it and subscribe