Write a Program in C language. In the written Hawaiian language, only 13 letters
ID: 644577 • Letter: W
Question
Write a Program in C language.
In the written Hawaiian language, only 13 letters are used: the five vowels (a,e,i,o, and u), and 8 consonants (h,k,l,m,n,p,w, and ` (this backwards apostrophe is called an `okina, and is considered a consonant)). (Unfortunately, there is no easy way to write the kahako in ascii text). For this problem you should write two functions, int is_vowel(char); and int is_h_consonant(char); which are each given a character and return True or False. The function is_vowel() returns True is the character is a vowel (upper or lower case), and is_h_consonant() returns True if the character is a consonant (upper or lower case) in written Hawaiian.
You should write a simple (throw away) test driver to test your functions. Be sure you prompt the user (grader) of your test driver on what they should do to test your program. You should write this program in two files; driver1.c containing your test driver, and letters.c containing your functions. You should also have a file, letters.h, containing the prototypes and macros used in letters.c. To compile this program, use the command:
Your executable will be called driver1.
Explanation / Answer
checkConsonant.c
------------------
int is_vowel( char ch){
if(ch=='a' ||ch=='A' || ch=='e' || ch=='E' || ch=='i' || ch=='I' || ch=='o' || ch=='O' || ch=='u' || ch=='U'){
return true;
}
else{
return false;
}
}
int is_h_consonant(char){
if(ch=='h' ||ch=='H' || ch=='k' || ch=='K' || ch=='l' || ch=='L' || ch=='m' || ch=='M' || ch=='n' || ch=='N'|| ch=='p' || ch=='P' || ch=='w' || ch=='W' || ch=='`'){
return true;
}
else{
return false;
}
}
-----------------------------------------------------------
header.h
-------------------------
int is_vowel();
int is_h_consonant();
----------------------------------
main.c
-----------------------------
#include "header.h"
#include <stdio.h>
main()
{
printf("Running... ");
/*
* Call is_vowel() and is_h_consonant()- defined in another file
*/
WriteMyString(MY_STRING);
boolean res = is_vowel('a');
boolean res1 = is_h_consonant('h');
printf("Finished. ");
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.