jeudi 21 octobre 2021

Can i find the biggest number out of 3 numbers using if statment but without using &&?

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Please enter your first number");
            int n1 = int.Parse(Console.ReadLine());
            Console.WriteLine("Please enter your secound number");
            int n2 = int.Parse(Console.ReadLine());
            Console.WriteLine("Please enter your third number");
            int n3 = int.Parse(Console.ReadLine());
            if(n1>n2)
            {if(n1>n3)
                {
                    Console.WriteLine("your 1st number is the biggest");
                }
                else
                {
                    Console.WriteLine("your 3rd number is the biggest");
                }
            }else if(n2>n1)
            {if(n1>n3)
                {
                    Console.WriteLine("your secound number is the biggest");
                }
                else if(n3<n2)
                {
                    Console.WriteLine("Your 3rd number is the biggest number");
                }


            }
            
                
            
        }
    }
    }

so i want to get the biggest number of of the 3 numbers the user will type but im trying to do it not using && and i think there is a problem in the program logic , and i feel like this type of if statment inside each other really make me confused

Aucun commentaire:

Enregistrer un commentaire