Question

Write a C program to “de-vowel” an input string. Assume that the user provides input containing...

Write a C program to “de-vowel” an input string. Assume that the user provides input containing only the characters a through z (i.e., all lowercase letters). Your program should create an output string that deletes all vowels from the input string, pushing the letters together to fill any gaps. For example, given the input “theturtleandthehare” your code should print out “thtrtlndthhr”. Your program should create an output string from the input string, before printing its output.

Sample Input: Enter a string: theturtleandthehare

Sample Output: De-vowel string is: thtrtlndthhr

Your program should use the following lines of code:

char input[80], output[80];

printf("Enter a string: ");

scanf("%s" , input);

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<stdio.h>
#include<string.h>
int main() {
char input[80], output[80];
int i,n,j=0;
printf("Enter a string: ");

scanf("%s" , input);
n = strlen(input);
for(i=0;i<n;i++) {
if(!(input[i]=='a' || input[i]=='e' || input[i]=='i'|| input[i]=='o'|| input[i]=='u')) {
output[j]=input[i];
j++;
}
}
output[j]='\0';
printf("De-vowel string is: %s\n", output);
}

Output:

Enter a string: theturtleandthehare

De-vowel string is: thtrtlndthhr

Add a comment
Know the answer?
Add Answer to:
Write a C program to “de-vowel” an input string. Assume that the user provides input containing...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that prompts the user to input a string. The program then uses the...

    Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str=”There”, then after removing all the vowels, str=”Thr”. After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel. #include <iostream> #include <string> using namespace std; void removeVowels(string& str); bool isVowel(char ch);...

  • // Write a program that determines how many of each type of vowel are in an...

    // Write a program that determines how many of each type of vowel are in an entered string of 50 characters or less. // The program should prompt the user for a string. // The program should then sequence through the string character by character (till it gets to the NULL character) and count how many of each type of vowel are in the string. // Vowels: a, e, i, o, u. // Output the entered string, how many of...

  • Write a C program that prompts the user for an input string with all lowercase letters....

    Write a C program that prompts the user for an input string with all lowercase letters. Your program should then sort the characters in the string and print the sorted string. Assume that the string contains no spaces and has at most 30 lowercase characters. Your program should loop continually until the user enters “q” to quit.

  • Write a basic ARM program that takes a string as input, then outputs a string that...

    Write a basic ARM program that takes a string as input, then outputs a string that replaces all the vowels in the input string with 'x'. Vowels: a, A, e, E, i, I, o, O, u, U. **I am using DS-5 Eclipse Community Workspace with ARM assembly language.** The program should give the following input prompt: "Input a string: " Then, the program should output the string with the vowel(s) replaced with x. The program should terminate upon printing the...

  • I'm having trouble getting my program to output this statement Enter a sentence: Test! There are...

    I'm having trouble getting my program to output this statement Enter a sentence: Test! There are 5 total characters. There are 1 vowel. There are 1 UPPERCASE letters. There are 3 lowercase letters. There are 1 other characters. Here's my code: #include<string.h> #include<stdio.h> #include<stdbool.h> int main() { char str[100]; int i; int vowels=0; int UC; int LC; int Others; int c; printf("Enter a sentence: \n"); gets(s); LC=countLC(&s); UC=countUC(&s); Others=countOthers(&s); printf("There are %d total characters.\n", ; for(i=0; i<strlen(str); i++){ if(isVowel(str[i])) vowels++;...

  • In Java, write a program that prompts the user to input a sequence of characters and...

    In Java, write a program that prompts the user to input a sequence of characters and outputs the number of vowels. You will need to write a method to return a value called isAVowel which will return true if a given character is a vowel and returns false if the character is not a vowel. A second method, called isAConstant, should return true if a given character is a constant and return false if the character is not a constant....

  • Write an LC-3 program (starting at memory location 0x3000) to take a string as input and...

    Write an LC-3 program (starting at memory location 0x3000) to take a string as input and then output information about this string. The end of the string will be denoted with the "#" character. Once the "#" has been found, output the following in order: 1) The letter “u” followed by the number of uppercase letters in the string (A-Z) 2) The letter “l” followed by the number of lowercase letters in the string (a-z) 3) The letter “n” followed...

  • Write a ALP that inputs a string and let's the user choose from uppercase or lowercase...

    Write a ALP that inputs a string and let's the user choose from uppercase or lowercase and vowel and consonant the characters/string to be saved in file. ASSEMBLY LANGUAGE MASM Sample output: Enter a string: RoSE A uppercase vowel B. Lowercase vowel C. Uppercase consonant D.Lowercase consonant Enter choice: c Saving... Program used is emu8086

  • This program should be run on Visual Studio. Please use printf and scanf as input and...

    This program should be run on Visual Studio. Please use printf and scanf as input and output. Thank you 6.11 Lab Exercise Ch.6a: Functions: String analyzer Create and debug this program in Visual Studio. Upload your Source.cpp file for testing (1) Prompt the user to enter a string of their choosing. Output the string. (1 pt) Ex: ics Enter a sentence or phrase: The only thing we have to fear is fear itself. You entered: The only thing we have...

  • Write a program which gives the user the option to separate, Vowels or Consonant from a...

    Write a program which gives the user the option to separate, Vowels or Consonant from a given text from a file. We will display the separated data on screen and also store it in output file. This is for C++ . Name of the input file to be used is: SeparateConVow.dat . The input file has this sentence: THIS IS THE FINAL PROJECT FOR OUR CLASS . The code should separate the vowels and consonants in that sentence. ^ ....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT