Sun Sep 05 2021

Smallest Number

File Name: smallest-number.java

import java.io.*;

class smallest {
	public static void main(String args[ ]) {
		int a = 5, b = 3, c = 10, d = 1;
		System.out.println("Program to show smallest number");

		/* Conditional statement */
		if(a < b) {
			if(a < c) {
				if(a < d)
					System.out.println("Smallest Number is: "+a);
				else
					System.out.println("Smallest Number is: "+d);
			}
			else {
				if(c < d)
					System.out.println("Smallest Number is: "+c);
				else
					System.out.println("Smallest Number is: "+d);
			}
		}
		else {
			if(b < c) {
				if(b < d)
					System.out.println("Smallest Number is: "+b);
				else
					System.out.println("Smallest Number is: "+d);
			}
			else {
				if(c < d)
					System.out.println("Smallest Number is: "+c);
				else
					System.out.println("Smallest Number is: "+d);
			}
		}
	}
}



/* Output */
Program to show smallest number
Smallest Number is: 1

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.