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