What are the mistakes i did in the code. It is not giving any output? [closed]

You have put a ; at the end of for loops and that’s the reason the body of the for loop is not being executed as expected.
Effect of semicolon after ‘for’ loop

for (i = 0; i < strlen(test) && (test[i] == '-'); i++);
for (; i < strlen(test););
for (; (i < strlen(test)) && (isdigit(test[i]) == 0); i++);
for (; (i < strlen(test)) && (isalpha(test[i]) == 0); i++);

Remove the ; from the end of each for loop.

You should also remove the inner for loop as it has already mentioned in the outer for loop. Please check the body of each for loop properly.

Leave a Comment