Here are two solutions.
bool anyAs(char s[]) { int i,len; len = strlen(s); for(i = 0; i < len; i++) { if(s[i] == 'a') return 1; } return 0; }
bool anyAs(char s[]) { int i; for(i = 0; s[i] != '\0'; i++) { if(s[i] == 'a') return 1; } return 0; }
n2
n
log2 n
11. (Repeatedly divide by two, and count how many steps it takes to reach 1. When a fractional result occurs, round up to the next integer.)
void rowSums(int T[20][20], S[20]) { int i,k,sum; for(i = 0; i < 20; i++) { sum = 0; for(k = 0; k < 20; k++) sum = sum + T[i][k]; S[i] = sum; } }
rowSums(Table,Sums);
You can get the length of a null-terminated string using strlen. So it is not necessary to be told the length. (Strlen does not work for all arrays. It only works for null-terminated strings.)