O1 NAME: Extra 1 5. (20 points) You are to write a function which h as a prototy
ID: 3720459 • Letter: O
Question
O1 NAME: Extra 1 5. (20 points) You are to write a function which h as a prototype ount(char ?[], int* pA 1 pha, int* pDigit. int * pvowe s [ is a character string which may be of any length and is an input to the The remaining arguments point to value which are to be set by the function pAlpha is the count of alphabetic characters in the string (A-2, a- pDigit is the count of digits in the string (0-9) pvowel is the count of vowels in the string (a.e.ou,A,E,100) For example (this is only an exa program) mple) the code (put into a propertly wrten a ["The Quick Brown Tiger Jumped Over the" char b22,247, 653,213 Really Lazy Zebras" char c[] = { "Madam, I'm Adam-number 1" ); int x,y,z Countchar (a, &a;, &b; , &c; ) ; print f ( "%d %d %d ", x, y, z); CountChar (b, &a;, &, &c;) printf("%d %d %d ", x, y, z); CountChar(c, &a;, &b; , &c;); printf("%d %d %d ", x, y, z); should print: 31 0 11 16 11 5 17 1 7 Do not write the main program (doing so will cost you points). You should only write the CountChar () function. The function should not have any scanf (), fgets(), or printf () function calls in it. Points will be deducted for using these functions. If you wish/need to write another function which CountChar () calls, that is OKExplanation / Answer
Submitting CountChar seprately method as per direction however i tested the program and running fine.
in above given example CountChar Method called withe wrong params they should call with x y z but then only used a
correct one - > CountChar(a,&x,&y,&z);
//countchar.c
#include<stdlib.h>
void CountChar(char a[],int* pAlpha, int* pDigit, int* pVowel){
//initializing each to 0 that not have any garbage value
*pAlpha = *pDigit = *pVowel = 0;
int i=0;
//looping until null char occured
for (i=0;a[i]!='';i++){
//if char is alphabets
if(isalpha(a[i])){
*pAlpha+=1;//increasing the count
}
//if char is vowel
if( a[i]=='a' || a[i]=='e' || a[i]=='i' || a[i]=='o' || a[i]=='u' ||
a[i]=='A' || a[i]=='E' || a[i]=='I' || a[i]=='O' || a[i]=='U'){
*pVowel+=1;//increasing the vowel count
}
//if char is digit
if(isdigit(a[i])){
*pDigit+=1;
}
}
}//end
//below is main method for demonstrating working but it should not be submitted only submit the avove code in bold otherwise marks got deducted.
int main(){
char a[] = "The Quick Brown Tiger Jumped Over the";
int x,y,z;
CountChar(a,&x,&y,&z);
printf("%d %d %d",x,y,z);
}
//OUTPUT
31 0 11
//Please do let me know if u have any concern...
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.