This code shows different output for same input.
Here is the code:
@naazsayma123 there are following mistakes in your code