Java program to find the largest & smallest number in n numbers without using arrays

前端 未结 8 1124
天命终不由人
天命终不由人 2020-12-22 14:22

I could get the largest without using arrays but, unable to get the smallest one.

    public static void main(String[] args)
    {
        int smallest=0;
           


        
8条回答
  •  孤城傲影
    2020-12-22 14:58

    Try this :

    int smallest = Integer.MAX_VALUE;
    for(int i=0;ilarge)
       {
           large=num;
       }
       if(num

提交回复
热议问题