Computer Science, asked by music77, 1 month ago

write a program to take two integers as input and check which one is greater. Print the message accordingly.


please answer me fast​

Answers

Answered by Anonymous
3

Since you haven't mentioned any language, I am assuming that the question is being asked for python.

Required program :-

a = int(input("Enter 1st number: "))

b = int(input("Enter 2nd number: "))

if a>b:

print(f"{a} is greater than {b}")

elif b>a:

print(f"{b} is greater than {a}")

elif a==b:

print("Both are same")

Explanation :-

  • Firstly take two integers values as input and store them in two variables say a and b. int() function converts the input to integer form.

  • Now use if else ladder to check if a is greater than b or b is greater than a and print the message accordingly by using f strings (f" ").

  • Now in case the user enters two same values, it should print Both the same.

  • You can use as many elif statement as per the need in if else ladder, else is optional and if should not be repeated.

Output attached . . .

Attachments:
Similar questions