all my test results are not executing properly.please help me out
That is not true, some of your tests do succeed. This is a good indicator that you did something right. Either you are being hard on yourself or you don’t understand what is happening. Also you should have formatted this code properly if your asking for help so that others can properly test the code themselves by selecting it. You can create a code block by placing your code between two sets of three backticks (```).
Now, looking at your code. Your function determines the appropriate characters along all of your breakpoints. By breakpoints I mean each major digit (1000, 100, 10) and your halfway breakpoints such as 50, and one above and below. However your function does not handle multiples of the single value representation such as I for 1 and X for ten.
A good example of your function working well is the test for 44. Because 40 is one less than 50, your loop adds “XL” and then subtracts 40 from 44 to get 4. Then it continues and because 4 is one less 5 it adds “IV”.
What happens if it was 43 though? It would only have added “I” to give you “XLI”. You might decide to hardcode the pairs such as adding “III”, “II”, “I” to romanN and also 3, 2 ,1 to p but I suggest you continue trying to finish your function so that it handles this problem properly.