Given a text, check if all vowels appear in the text. Use while loop , getchar and no arrays. C language
#include <stdio.h> #include <stdlib.h> #include <ctype.h> int main() { char ch; int A = 0, E = 0, I = 0, O = 0, U = 0; printf("Enter text ('|' to terminate):\n"); ch = getchar(); while (ch != '|') { ch = tolower(ch); if (ch == 'a') A = 1; else if (ch == 'e') E = 1; else if (ch == 'i') I = 1; else if (ch == 'o') O = 1; else if (ch == 'u') U = 1; ch = getchar(); } if (A && E && I && O && U) printf("TRUE"); else printf("FALSE"); return 0; }
Note: The getchar() is used to read inputs from stdin. Hence it used to read text from input stream.
Get Answers For Free
Most questions answered within 1 hours.