Instructions:
Write a program that will have the user enter a letter.
Solution:
Write a program that will have the user enter a letter.
- If the letter is a vowel, the output will report that the user has entered letter ??? and that it is a vowel.
- Otherwise, the output will report that the user has entered letter ??? and asks them to please enter a vowel.
- The program will run until the user enters x.
- The user may enter the letter in either uppercase or lowercase and the program will execute properly.
Solution:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main()
{
char ch, tmpCh;
printf("*********Welcome to Program**********\n");
printf("Enter the Char: \n");
scanf(" %c", &ch);
tmpCh = (toupper(ch));
while (tmpCh != 'X')
{
if (!isalpha(ch) || (int)ch == 45)
{
printf("Please Enter Valid Char.\n");
printf("\nPlease press any key to continue: ");
char reCh;
reCh = getc(stdin);
if (reCh == 10)
{
reCh = getc(stdin);
}
system("clear");
printf("*********Welcome to Program**********\n");
printf("Enter the Char: \n");
scanf(" %c", &ch);
tmpCh = (toupper(ch));
}
else
{
if (tmpCh == 'A' || tmpCh == 'E' || tmpCh == 'I' || tmpCh == 'O' || tmpCh == 'U')
{
printf("You have enter Valid Vowel which is %c \n", ch);
printf("\nPlease press any key to continue: ");
char reCh;
reCh = getc(stdin);
if (reCh == 10)
{
reCh = getc(stdin);
}
system("clear");
printf("*********Welcome to Program**********\n");
printf("Enter the Char: \n");
scanf(" %c", &ch);
tmpCh = (toupper(ch));
}
else
{
printf("You have enter letter which is not Vowel which is %c \n", ch);
printf("\nPlease press any key to continue: ");
char reCh;
reCh = getc(stdin);
if (reCh == 10)
{
reCh = getc(stdin);
}
system("clear");
printf("*********Welcome to Program**********\n");
printf("Enter the Char: \n");
scanf(" %c", &ch);
tmpCh = (toupper(ch));
}
}
}
return 0;
}
Nicely use toupper() function to cover forth step
ReplyDeletethanks
DeleteThe welcome supply goes a lot as} $7,500 should 카지노사이트 you use crypto, and we additionally suggest trying out the Rewards Program and the VIP section. It's easy - you play games, and you earn bonus points for extra goodies and perks. This on-line on line casino is mobile-friendly, however we now have a minor quibble with the exclusion of some of the the} slots within the cellular version.
ReplyDeleteGreat blog ! I am impressed with suggestions of author.
ReplyDeleteOrganic Clothing