Q. Consider the following code segment:


a = input()

b = int(input())

c = a + b

print(c)

 

When the program is run, the user first enters 10 and then 5, it gives an error. Find the error, its reason and correct it.

 

Answer =

 

Correct program:-

 

a = int (input())

b = int(input())

c = a + b

print(c)

 

Reason:- string value and integer value cannot add.

5 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post