question archive Write a function named Itrcount that will take a single string argument containing any legal character and return the number of characters in the string that are alphabetic letters (lower-case a-z or upper-case A-Z)

Write a function named Itrcount that will take a single string argument containing any legal character and return the number of characters in the string that are alphabetic letters (lower-case a-z or upper-case A-Z)

Subject:Computer SciencePrice:9.82 Bought3

Write a function named Itrcount that will take a single string argument containing any legal character and
return the number of characters in the string that are alphabetic letters (lower-case a-z or upper-case A-Z).
Test your function using the command-line interface with the following strings:

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

Code.

Step-by-step explanation

#include <stdio.h>

// function to return count of '!' in s

int count_bangs(char *s){

int index = 0, count = 0;;

// while there are more charaters in the string

while(s[index]!='\0'){

// increase the index value

index++;

// if the element at current index is '!'

// increase its count

if(s[index] == '!'){

count ++;

}

}

// return total count

return count;

}

void main(){

// declare and initialize a char pointer

char *s = "Hello!, I am Chegg!!!";

// call the function

int count = count_bangs(s);

// print the result

printf("Total '!' in the string '%s' is = %d", s, count);

}