nd ` (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. I have provided a makefile for you in ~ee160/Homework/Hw3 which you can copy to your Hw3 directory. To compile this program, use the command:
make driver1
THIS IS WHAT I HAVE SO FAR:
LETTERS.C
#include"letters.h"
int is_vowel(char c){
return c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U' || c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
}
int is_h_consonant(char c){
return c == 'H' || c == 'h' || c == 'K' || c == 'k' || c == 'L' || c == 'l' || c == 'M' || c == 'm' || c == 'N' || c == 'n' || c == 'P' || c == 'p' || c == 'W' || c == 'w';
}
LETTERS.H
int is_vowel(char);
int is_h_consonant(char);
DRIVER1.C
#include
#include"letters.h"
int main()
{
while(1)
{
int input;
//Asks the user to enter 1 or 2 to see if the letter is a consonant
//of vowel.
printf("Enter 1 to check vowel or 2 for consonant:");
//scans inputted number
scanf("%i", &input);
//if the input is 1 then it will ask the user to enter the letter
//they want to test.
if(input == 1)
{
char c;
printf("Enter a character to test if it's a vowel:");
c = getchar();
//if it is a vowel, then it will print that the letter is a vowel
if(is_vowel(c))
{
printf("%c is a vowel.\n", c);
}
//if not, then it will print that it isn't a vowel
else
{
printf("%c is not a vowel.\n", c);
}
}
{
//if the user inputs 2, then it will ask the user for the letter to test if
//it's a consonant or not.
if(input == 2)
{
char c;
printf("Enter a character to test if it's a consonant:");
c = getchar();
//if it is a consonant, then it will print that the letter is a consonant
if(is_h_consonant(c))
{
printf("%c is a consonant.\n", c);
}
//if not, then it will tell the user that it isn't a consonant
else{
printf("%c is not a consonant.\n", c);
}
}
else{
break;
}
}
}
return 0;
}
THIS IS WHAT I GET AS A SAMPLE OUTPUT:
Enter 1 to check vowel or 2 for consonant:2
Enter a character to test if it's a consonant:
is not a consonant.
Enter 1 to check vowel or 2 for consonant:1
Enter a character to test if it's a vowel:
is not a vowel.