Does anyone know what i'm doing wrong here? won't run and comes up with an error saying there's an expected expression before ||
>>51808168
Check your parentheses, the || is outside of the if(...).
>>51808168
you spelled capitalize wrong.
You need encapsulating outer parens on your entire if clause, broheim
you aren't nesting your 'if' statement properly/* you have: */
if ((name[0] >= 'P') && (name[0] <= 'S')) || ((name[0] >= 'p') && (name[0] <= 's'))
/* should be */
if ((name[0] >= 'P') && name[0] <= 'S') || (name[0] >= 'p' && (name[0] <= 's'))
>>51808220
also, this.
jesus christ programming is confusing that's why i am liberal arts major
>>51808321
xkcd?
>>51808223
>>51808226
>>51808233
>>51808245
>>51808220
I changed it to this, is there anything else I need to do? what do you mean by || being out of the "if" statement, and how do i include it?
nevermind i got it, thanks 4 chan. I don't know how many times i've used this website, but i'd be lost without it!
>>51808462
Jesus.
>>51808462
glad to help. know that I accidentally added too many parenthesis and you can get by with justif ((name[0] >= 'P' && name[0] <= 'S') || (name[0] >= 'p' && name[0] <= 's'))
if ( (this & that) OR (this & that) )
keep at it, mate
>>51808524
you don't have to but here's my skype; harrison.king5 if it's okay you can add me, and if i have troubles in the future then i might ask, although i understand if that's too much
youre using an ide
>>51808168
missing a parens in if clause line 10
>>51808233
That's wrong, retard.
ASCII A: 65 - 90
ASCII a: 97 - 122/*
This function returns the lower case of a character if it is an upper case character.
*/
char lowerChar(char c) {
return c >= 97 && c <= 122 ? c - 32;
}
// your code, now without repeating yourself:
char curr = lowerChar(name[0]);
if (curr >= 'p' && curr <= 's') {
// your code here
}
// And this is how I would code it myself:
if (lowerChar(name[0]) >= 'p' && lowerChar(name[0]) <= 's') {
// your code here
}
>>51809218
Ah forgot to finish my ternary in the function. Typo, just need to return c if it's not an upper case letter.
Fix:char lowerChar(char c) {
return c >= 97 && c <= 122 ? c - 32 : c;
}
>>51809218
>>51809238
the C standard library already includes `tolower'
Try using an editor that highlights matching parentheses when you move the cursor over them.
>>51808462
Not like it really makes a big difference in your code, but you might find getting familiar with toupper/tolower makes things that aren't case sensitive easier.
You essentially get to get rid of the OR.