Question

and then print their average. Write a C program that accepts a string of text from the user and prints back the string without any of the vowels. For example, if the user entered Hello, world, the program should print Hll, wrld Write a C program that accepts an integer in decimal from the user and prints the number of 1 bits in the integers binary representation. For example, if the user entered 14, the program should print 3 because 14 is 1110 in binary Write a C program that reads two decimal numbers x and n from the user, and prints true if the nth bit of x is a 1 and false otherwise. For example, if the user enters 17 and O, the program should print true because 17 is 10001 in binary and bit 0 is a1. 4. 5. 6.
0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <stdio.h>
#include <string.h>

int main(void) {
        // to store user input
        char str[100];

        printf("Enter your string: ");

        // read the user entered string with spaces
        fgets(str, 100, stdin);

        printf("%s\n", str);

        int len = strlen(str);
        int i;

        // print characters from left to right
        for(i=0; i<len; i++) {
                char c = str[i];
                int isLowercaseVowel, isUppercaseVowel;
                isLowercaseVowel = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');

                // evaluates to 1 (true) if c is an uppercase vowel
                isUppercaseVowel = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U');

                if (!isLowercaseVowel && !isUppercaseVowel) {
                        printf("%c", c);
                }
        }
        printf("\n");

}

saved share gcc version 4.6.3 1 Enter your string: Hello Nord! Hello World! main.cLO 1 #include <stdio.h> Hll Wrld! #includeHi. please find the code.. i have given code comments so that it is very easy for you to understand the flow. In case of any doubts, please ask in comments. If the answer helps you, please upvote. Thanks!

Add a comment
Know the answer?
Add Answer to:
and then print their average. Write a C program that accepts a string of text from...
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 JAVA program that has a method which accepts a string and prints it back...

    Write a JAVA program that has a method which accepts a string and prints it back to the user with all vowels replaced with *'s (multiple asterisks not '*s') with a new line after the string. The method signature should look like this: public static void replacePrint(String input)

  • Write a program that prompts the user to enter a binary string and displays the corresponding...

    Write a program that prompts the user to enter a binary string and displays the corresponding decimal integer value. For example, binary string ‘10001’ is 17 (1*24 +0*23 +0*22 +0*2 + 1 = 17) A sample run : Enter a binary: 10001 17 Enter second integer: 110 6 Use python.

  • (C++ only) Write a function that returns a decimal number from a binary string. The function...

    (C++ only) Write a function that returns a decimal number from a binary string. The function header is as follows: int bin2Dec(const string& binaryString) For example, bin2Dec("10001") returns 17. Write a test program that prompts the user to enter a binary number as a string and displays its decimal equivalent value Sample Input: 1110100110101 Sample Output: Enter a bianry number: 1110100110101 7477

  • Write a program with a function that accepts a string as an argument and returns a...

    Write a program with a function that accepts a string as an argument and returns a copy of the string with the first character of each sentence capitalized. For instance, if the argument is “hello. my name is Joe. what is your name?” the function should return the string “Hello. My name is Joe. What is your name?” The program should let the user enter a string and then pass it to the function. The modified string should be displayed.

  • Write a program in MIPS to accept a string from a user, reverse that string and...

    Write a program in MIPS to accept a string from a user, reverse that string and print it out to the user. You must write a procedure that performs the reversal task. Example: Please Enter a String: Hello How Are You Reversed String: uoY erA woH olleH

  • Write a C++ program which accepts username and password from user and then print on the...

    Write a C++ program which accepts username and password from user and then print on the screen whether the user is authenticated or not. Also, upon entering the wrong credentials (username and password) three times, the program must exit. The program must print the appropriate messages if the user enters wrong username or password.

  • Write a C++ program that accepts a string from the user and then replaces all occurrences...

    Write a C++ program that accepts a string from the user and then replaces all occurrences of the letter e with the letter x.

  • Write a program that will ask the user for a decimal number such as 18 and...

    Write a program that will ask the user for a decimal number such as 18 and prints the 16 bit binary equivalent of the number: 0000 0000 0001 0010 NOTE: Your output should be a binary string formatted by nibbles (spaces every four bits): 0000 0000 0010 1110 1010 0111 1. Ask the user for a number and store it in an int variable called “number”. 2. Find out how many bits you want to use to represent this number....

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

  • Write a C++ program that will count the number of words and vowels in a sentence....

    Write a C++ program that will count the number of words and vowels in a sentence. Create a bool function called isVowel that accepts a character as a parameter and returns a true if it’s a vowel (aeiou) and false otherwise. Create an int function named countVowels that will accept a string variable as a parameter and will return the number of vowels in it. Call the isVowel function as part of this process. Write an int function named countWords...

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