Question

Given a text, check if all vowels appear in the text. Use while loop , getchar...

Given a text, check if all vowels appear in the text. Use while loop , getchar and no arrays. C language

Homework Answers

Answer #1

#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.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Lab Assignment | Count vowels Write a program that will use a while loop to count...
Lab Assignment | Count vowels Write a program that will use a while loop to count and display the number of vowels in the string provided as input by the end-user. This program will consider the letters a, e, i, o, and u (both upper and lower case) to be vowels. The user may enter a single word, a sentence, a paragraph, or nothing at all as input. Be sure to test each possibility. Python 3 please!
1) In Python Use a while loop to ask the user to enter a series of...
1) In Python Use a while loop to ask the user to enter a series of alphabets. The loop terminates when the user presses enter. Once the loop terminates, display the number of vowels and consonants entered by the user. Hint: keep a running count of the number of characters entered by the user. Keep a running count of the number of vowels. Total number of consonants = total number of characters - total number of vowels. Assume that the...
Uses a while loop to print the numbers from 3 - 19. Uses a do-while loop...
Uses a while loop to print the numbers from 3 - 19. Uses a do-while loop to print the numbers from 42 - 56. Uses a for loop to print the numbers from 87 - 95. Asks the user for 2 numbers. Uses a loop to print all numbers between the given numbers, inclusive. Note: Consider that your user's second number can be lower! (see example below) Note: Also consider that your user might give you two of the same...
Write a python while loop that sums all the numbers from m to n, where “m”...
Write a python while loop that sums all the numbers from m to n, where “m” and “n” are both user given values.
im trying to make a program that will use a while loop to repeatedly ask a...
im trying to make a program that will use a while loop to repeatedly ask a user for a test score. Use a counter to exit the loop when the user has entered 10 test scores. The loop is to figure out the total of all the scores and the highest score. it must use a while loop please explain problems in code the bottom code is my work done but does not work. #include <iostream> using namespace std; int...
Calculate and print the area and volume of a cone inside a While  loop that goes from...
Calculate and print the area and volume of a cone inside a While  loop that goes from 1 to 20 with a step of .5. (the step is 1/2 or Point 5, so you go 10, 10.5,11, 11.5) Note: Your loop variable will need to be a double data type Use two decimal places on all numbers that are double data type. This will be a table with 3 columns. Use r as the loop counter and as the radius. Let...
use python Write a program that uses a for loop to display all prime numbers within...
use python Write a program that uses a for loop to display all prime numbers within the range [500, 800] (hint: prime numbers are numbers that have only 2 factors: 1 and themselves. You can use a loop function to check if a number has a factor other than 1 or itself using % operation)
IN RUBY LANGUAGE. Write a single Ruby demo program that illustrates the use of all main...
IN RUBY LANGUAGE. Write a single Ruby demo program that illustrates the use of all main Ruby iterators (loop, while, until, for, upto, downto, times, each, map, step, collect, select, reject). The program should have a few lines illustrating loop, followed by a few lines illustrating while, and so on). PLEASE HAVE COPYABLE CODE. NOT A PICTURE. THANK YOU.
Write a program with while loop that prints all numbers between 5 and 100 (inclusive) that...
Write a program with while loop that prints all numbers between 5 and 100 (inclusive) that are divisible by 5.
Create a program that copies the data from one file to another while converting all lowercase...
Create a program that copies the data from one file to another while converting all lowercase vowels to uppercase vowels. Your program should accept two arguments: an input file to read from and an output file to copy to. • Your program should check to make sure the output file does not already exist. If it does, print "DESTINATION FILE EXISTS." to stdout. • Print the number of characters changed to stdout using the format string "%d characters changed." •...