Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7416487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:30:29+00:00 2026-05-29T07:30:29+00:00

I have been working on this all day with no luck. Its night now

  • 0

I have been working on this all day with no luck. Its night now and don’t know what to do. My assignment is to read number of vowels, number of white spaces, and number of other characters in a user inputted sentence. I know i need to use cin.get(ch) for whitespaces, but don’t know how. I also need to output the sentence to a file. Heres what I have so far:

//Get data from user 
cout << "Enter your sentence on one line followed by a # to end it: " << endl;



while (cin >> noskipws >> character && character != '#')
{
    character = static_cast<char>(toupper(character));

    if (character == 'A' || character == 'E' || character == 'I' ||
            character == 'O' ||  character == 'U')
    {
        vowelCount++;
        isVowel = true;

    }

    if (isspace(character))
    {
        whiteSpace++;

    }

    else if (isVowel == true && isspace(character))
    {
        otherChars++;
    }

    outFile << character;

}


outFile << "vowelCount: " << vowelCount << endl;
outFile << "whiteSpace: " << whiteSpace << endl;
outFile << "otherchars: " << otherChars << endl;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:30:29+00:00Added an answer on May 29, 2026 at 7:30 am
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        char ch;
        int vowel_count = 0;
        int space_count = 0;
        int other_count = 0;
    
        cout << "Enter a string ends with #: " << endl;
    
        while(1)
        {
            cin.get(ch);
            if(ch == '#')
            {
                break;
            }
    
            if(ch == 'A' || ch == 'a'
                || ch == 'E' || ch == 'e'
                || ch == 'I' || ch == 'i'
                || ch == 'O' || ch == 'o'
                || ch == 'U' || ch == 'u')
            {
                ++vowel_count;
            }
            else if(ch == ' ')
            {
                ++space_count;
            }
            else
            {
                ++other_count;
            }
        }
    
    
        cout << "Vowels: " << vowel_count << endl;
        cout << "White spaces: " << space_count << endl;
        cout << "Other: " << other_count << endl;
    
        return 0;
    }
    

    No arrays

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been working at this all day so I hope I don't forget any
I have been working all day but unable to achieve this : It is
I have been working on this all day, much of my code is from
I've been working on this all day now, and I just can't get it
I have been trying this all day now, and I am about ready to
Maybe its because I have been working all day and I can't see the
Ok, I have been working on solving this problem all day, and I am
I've been stuck on this all day, I have a script I'm working with
I have been working on this problem for 2 days now and it's an
I have been working on this for days but I don't get it so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.