Write a function called is_ consonant () that accepts a file handle (FILE *) to
ID: 3885454 • Letter: W
Question
Write a function called is_ consonant () that accepts a file handle (FILE *) to an already opened file and a character as input parameters, and returns 0 (false) if the character is NOT a consonant character, and 1 (true) if the character is a consonant character. The function should also write "is a consonant" or "is not a consonant" to the output file. A consonant is defined as any alphabetic (a - z) character uppercase or lowercase that is not a vowel. You may NOT use any functions found in .Explanation / Answer
#include<stdio.h>
int is_consonant(FILE *fp, char ch)
{
if (ch != 'a' && ch!='e' && ch != 'i' && ch != 'o' && ch != 'u' &&
ch != 'A' && ch!='E' && ch != 'I' && ch != 'O' && ch != 'U'){
fprintf(fp," %c is consonant ",ch);
return 1;
}
else {
fprintf(fp," %c is not consonant ",ch);
return 0;
}
}
int main(){
FILE *fp;
fp = fopen("charout.txt","w");
printf("%d ",is_consonant(fp,'a'));
printf("%d ",is_consonant(fp,'b'));
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.