Computer Science, asked by pbguardian07, 24 days ago

Write a program to take as input two integers. Then you have to display the larger number and the difference of the larger and the smaller number in two separate lines.

Answers

Answered by BrainlyProgrammer
6

Answer:-

//Java

//Assuming it is Java programming

import java.util.*;

class abc{

public static void main (String ar []){

Scanner sc=new Scanner(System.in);

int a=sc.nextInt();

int b=sc.nextInt();

if(a>b){

System.out.println(a);

System.out.println("Difference="+(a-b));

}

else if(b>a){

System.out.println(b);

System.out.println("Difference="+(b-a));

}

else

System.out.println("Both the numbers are same");

}

}

#Python Approach

a,b=(int)(input()),(int)(input())

if (a>b):

‎‎‎‎print(a,"\nDifference=",(a-b))

elif (b>a):

‎‎‎‎print(b,"\nDifference=",(b-a))

else:

‎‎‎‎print("Both the numbers are same")

Logic:-

  • Check which number is greater
  • Print that number and the difference
Attachments:
Answered by yadavashish211104
2

Answer:

a=int(input("Enter first number:"))

b=int(input("Enter second number:"))

if a>b:

   print(a,"is the larger than",b,"\nAnd difference btw them is",a-b)

elif b>a:

   print(b,"is the larger than",a,"\nAnd difference btw them is",b-a)

else:

   print("Both the numbers are same")

Explanation:

Similar questions