Computer Science, asked by mohanranjan5073, 10 months ago

Write a program to print the largest of three numbers?

Answers

Answered by neelrambhia03
9

Answer:

// Print largest of 3 no.s

import java.util.*;

class Print

{

public static void main(String args[])

{

Scanner sc = new Scanner(System.in);

int a,b,c;

System.out.print("Enter 3 no.s\n");

if(a>b)

{

if (a>c)

System.out.println(a+"is the largest");

else if(c>a)

System.out.println(c+"is the largest");

}

if(b>a)

{

if (b>c)

System.out.println(b+"is the largest");

else if(c>b)

System.out.println(c+"is the largest");

}

if(c>b)

{

if (a>c)

System.out.println(a+"is the largest");

else if(c>a)

System.out.println(c+"is the largest");

}

}

}

Hope this helps you.

Answered by Shazzad
10

Answer:

Explanation:

#include <stdio.h>

int main()

{

   double n1, n2, n3;

   printf("Enter three different numbers: ");

   scanf("%lf %lf %lf", &n1, &n2, &n3);

   if( n1>=n2 && n1>=n3 )

       printf("%.2f is the largest number.", n1);

   if( n2>=n1 && n2>=n3 )

       printf("%.2f is the largest number.", n2);

   if( n3>=n1 && n3>=n2 )

       printf("%.2f is the largest number.", n3);

   return 0;

}

Similar questions