Question

In: Computer Science

3. Write a function named "countNonAlpha" that accepts a string. It will return the number of...

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!

Solutions

Expert Solution

#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


Related Solutions

Write a function named "characters" that takes a string as a parameter and returns the number...
Write a function named "characters" that takes a string as a parameter and returns the number of characters in the input string
C++ Please Define a function named "isAscending" that accepts a string as an input parameter and...
C++ Please Define a function named "isAscending" that accepts a string as an input parameter and returns "true" if all the characters included in the string are ordered in ascending order of their ASCII codes or the input string is a null string, and returns "false" otherwise. For example, if the string "ABXab" is passed to the function, it returns "true" because the ASCII code of 'B' is greater than 'A', 'X' is greater than 'B', 'a' is greater than...
Language: Python 3 Compose a function process which accepts a string filename. process should return a...
Language: Python 3 Compose a function process which accepts a string filename. process should return a list of records contained in the file. #define your function here # Create a blank list called `entries` and an empty string called `current_style`. # Open the file `filename`, read the data using readlines(), and close it. # Loop through each line of the file and do the following: # Strip the whitespace off of the ends of the line using the `strip` method....
Write a python function to fulfill the requirements. The function accepts a string, a current state,...
Write a python function to fulfill the requirements. The function accepts a string, a current state, edges’ information, and an accepting state. The output of the function is a boolean value verifying if the string can pass the finite state machine or not.             ### Finite State Machine Simulator in Python ### Provide s1 and s2 that are both accepted, but s1 != s2. s1 = "bdf" s2 = "bdgbdf" edges = {(1,'a') : 2,                (1,'b') : 3,       ...
In Java, write a recursive function that accepts a string as its argument and prints the...
In Java, write a recursive function that accepts a string as its argument and prints the string in reverse order. Demonstrate the function in a driver program.
Write a function, named isMultipleOfFive that accepts integer argument. When the function is called, it should...
Write a function, named isMultipleOfFive that accepts integer argument. When the function is called, it should display if the argument "is a multiple of 5" or "is not a multiple of 5".
-Write in C++ -Use Char library functions Write a function that accepts a string representing password...
-Write in C++ -Use Char library functions Write a function that accepts a string representing password and determines whether the string is a valid password. A valid password as the following properties: 1. At least 8 characters long 2. Has at least one upper case letter 3. Has at least one lower case letter 4. Has at least one digit 5. Has at least on special character
In a program, write a function that accepts two arguments: a list, and a number n....
In a program, write a function that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all of the numbers in the list that are greater than the number n. The program should ask for a list of numbers from the user as well as a value (a, b, c)--> inputs from user. After that, each number in that list should be compared to that value (a or b or...
write a function named as cubeCalculator that takes an integer pointer as function and return its...
write a function named as cubeCalculator that takes an integer pointer as function and return its cube value , you are required to compute the cube of a number using pointer notation , return the result as an integer value , use c++
USING JAVASCRIPT Create a file name dayOfWeek.js and write an arrow function named dayOfWeek that accepts...
USING JAVASCRIPT Create a file name dayOfWeek.js and write an arrow function named dayOfWeek that accepts a Date object dateStr and returns a string that is the day of the week in English form (i.e. “Sunday”, “Monday”, etc.). Test your function by creating a date object that is a significant date to you (such as your birthday) and passing that date object to your function. Test your function at least twice with two different dates. Submit the dayOfWeek.js file to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT