In: Computer Science
3. Write a function named "countNonAlpha" that accepts a string.
It will return the number of non-alphabet characters (excluding
blanks) in the string.
For example, if the string is "Hello, World!", it will return 2 for
',' and '!" in the string.
4. Write a function named "deleteZeros" that takes two
arguments:
a. an array of integer values;
b. an integer for the number of elements in the array;
The function will return the number of zeros that it has deleted
from the array
The function should shift the contents of each element in the array
whenever a zero
element is deleted
For example, if the array is defined as
int numList[] = {10, 0, 20, 30, 40, 0, 50};
The function will return 2 and shift to make the array to
contain
10 20 30 40 50
5. Write a function named "reverseCase" that takes only one
argument of a C-string (an array of characters that terminates with
a NULL ('\0') character).
The function will change all lower cases to upper case and vice
versa in that given
C-string. If the character is not an alphabet, it will be
unchanged.
The function will return the number of letters that it has
changed.
For example, if the array is defined as
char greeting[] = " Hello, World! ";
It will return 10 and change the array to contain
hEELO, wORLD!
#include<stdio.h>
int countNonAlpha(char *str){
int count=0;
for(int i=0;str[i]!='\0';i++){
char ch=str[i];
if( !((ch >= 97 && ch <= 122) || (ch >= 65
&& ch <= 90)))
if(ch!=' ')
count++;
}
return count;
}
int main(){
char *str="Hello, World!";
printf("%d",countNonAlpha(str));
}
As per policy we can answer 1 question per post. Please post the remianing questions as separate post.Thanks