Write a function which has a prototype: int nonletter(char s[]); s[] is a charac
ID: 3697311 • Letter: W
Question
Write a function which has a prototype: int nonletter(char s[]); s[] is a character string which may be of any length. The function is to parse (check character by character) the string and count the number of non letters. The function should return this value. For example (this is only an example) the code (put into a properly written program): should print: 14 6 4 Do not write the main program (doing so will cost you points). You should only write the nonletter () function. The function should not have any scanf (), gets (), or printf () function calls in it. Points will be deducted for using these functions. If you wish/need to write another function which nonletter () calls, that is OK.Explanation / Answer
int isnon(char ch)
{
if(ch>='a' && ch<='z')
return -1;
if(ch>='A' && ch<='Z')
return -1;
return 1;
}
int nonletter(char s[])
{
int len = strlen(s);
int i,j,k;
int count=0;
for(i=0;i<len;i++)
{
if(isnon(s[i])==1)count++;
}
return count;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.