Computer Science, asked by singhthakuryash09, 7 months ago

write a program to input an integer and if positive ,change it to negative,and if negative change it to positive
input enter an integer 12
sign changed -12
input enter an integer 14
sign changed -14

Answers

Answered by shivakumarjagadish12
1

Answer:

num = int(input('Enter a number: '))

if num > 0 or num < 0:

    print(convert(num))

else:

    print('zero is neither postive nor negative.')

Explanation:

this check is if it is positive or negative then converts to the opposite, if the number is '0' then i will print 'zero is neither postive nor negative.'

hope it helped ya!

Answered by anindyaadhikari13
1

Question:-

  • Write a program to input an integer and if positive ,change it to negative,and if negative change it to positive.

Program:-

This is written in Python.

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

n=n*-1

print("Result is: "+n)

Similar questions