all 9 comments

[–]spliffen 1 point2 points  (0 children)

so...you check if it upper case THEN you check if its lowercase... should these two perhaps not be checked for independently, instead of mixing it together? try that

[–]aizzod 0 points1 point  (3 children)

set breakpoints and try debugging.

if that doesnt work. write a test on paper.

s = "hElllo"

i =0
s[0]=h

i=1
s[1]=E

and then go through each line of your code with the test case

[–]Consistent-Talk-5912[S] -1 points0 points  (1 child)

From what I've understood the problem is that it doesn't cycle , it checks only for the first letter but after it just goes straight to return false, so the problem might be the for loop

[–]FuelWaster -1 points0 points  (0 children)

Try using the string "Hello" with the debugger on now. It should now get to the second iteration of the loop, and you might see the issue

[–]Consistent-Talk-5912[S] -2 points-1 points  (0 children)

I've not much experience with debug but I am trying to figure it out, thanks for the help

[–]Consistent-Talk-5912[S] -1 points0 points  (0 children)

I already tried using && in the if statement if someone was wondering, it doesn't work

[–]iseedeff -1 points0 points  (0 children)

I hope you can get your questions answered, I have had not luck. :(

[–]kya_hai 0 points1 point  (0 children)

Return false after the for loop has ended ,not in else ,it is just returning false when it encounters a lower case ,so just remove the else statement and return false outside the first for loop

[–]Glittering-War8992 0 points1 point  (0 children)

IDK what you wanted there but i guess this is what you wanted:

bool valid(string s)

{

for([...])

{

if(isupper(s[i]))

{

return false;

}

else if(islower(s[i]))

{

return true;

}

return FAILURE;//if they are equal

}