2
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int vovles_count[5] = { 0,0,0,0,0 };
    char vovwls[5] = { 'a','e','i','o','u' };
    char vov;
    int nonVov = 0 , punt = 0 , douseq = 0;

    //std::cin >> std::noskipws; //tells not to skip white spaces

    while (cin >> vov)
    {
        switch (vov)
        {
            case 'a':
                ++vovles_count[0];
                break;
            case 'e':
                ++vovles_count[1];
                break;
            case 'i':
                ++vovles_count[2];
                break;
            case 'o':
                ++vovles_count[3];
                break;
            case 'u':
                ++vovles_count[4];
                break;
            case ' ':
                ++punt;
                break;
            case '\n':
                ++punt;
                break;
            case 'f':
                cin >> vov;
                if (vov == 'l' || vov == 'f')
                {
                    ++douseq;
                    ++nonVov; //previous f
                    ++nonVov; //current f

                } 
                else if (vov == 'i')
                {
                    ++vovles_count[2];
                    ++douseq;
                    ++nonVov;   //previous f
                }
                else if (vov == ' ' || vov == '\n')
                    ++punt;

                break;
            default:
                ++nonVov;
                break;

        }
    }
    for (int i = 0; i < 5; ++i)
    {
        cout << vovwls[i] << " occured for " << vovles_count[i] << "times" << '\n';
    }
    cout << '\n' << nonVov << " are the occurence of non vovels " << '\n' ;
    cout << '\n' << punt << " are the occurence of whitespaces " << '\n';
    cout << '\n' << douseq << " are the occurence of double sequence " << '\n';


    system("pause");
    return 0;
  }

I dont think i see any problem in the code but i don't know why white spaces are not being read?

psrag anvesh
  • 1,257
  • 2
  • 12
  • 18

1 Answers1

0

using cin will skip white space by default. you can try other ways:

cin.get();

exactly this code overload of function would help you:

istream& get (char* s, streamsize n, char delim);

put '\n' in delim to end input line on pushing enter

reza
  • 1,746
  • 6
  • 16
  • 32