simple java programming questions for beginners.
Simple java programming questions.
Q1 .Write a program to accept two numbers from user and find the greater one.
Ans :-
import java.util.*;
class Number
{
int a,b;
public void main()
{
scanner sc = new Scanner(System.in);
System.out.println("Enter any two numbers");
a=sc.nextInt();
b=sc.nextInt();
{
if (a>b)
System.out.println (" Greater Number="+a);
{
else
Syatem.out.println ("Greater Number ="+b);
}
}
}
Comments
Post a Comment