Answer to Question #342876 in C++ for Padi

Question #342876

Write function headers for the functions described below:

(iv) The function countChar returns the number of occurrences of a character in a string, both provided as parameters


1
Expert's answer
2022-05-20T14:05:54-0400
int countChar(char character, char* text){
    int counter =0;


    for(int i =0; i<sizeof(text)/sizeof(text[0]) ;i++){
        if(text[i]==character)  counter++;
    }
    return counter;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS