Code:
#include <iostream>
#include <conio.h>
#include <cstring>
using namespace std;
int main()
{
char suglasnici [43] = {'b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z','B','C','D','F','G','H','J','K','L','M','N','P','Q','R','S','T','V','W','X','Y','Z','\0'};
char slovo;
int sam = 0;
int sug = 0;
int i;
cout << "Upisite slova. Za kraj upisite malo slovo a: " << endl;
do
{
slovo = getche();
cout << " ";
if (slovo=='a'||slovo=='e'||slovo=='i'||slovo=='o'||slovo=='u'||slovo=='A'||slovo=='E'||slovo=='I'||slovo=='O'||slovo=='U')
{
sam++;
}else
{
for(i=0;i<strlen(suglasnici);i++)
{
if(slovo == suglasnici[i])
{
sug++;
}
}
}
}while(slovo!='a');
cout << "\nBroj samoglasnika je: " << sam << endl;
cout << "Broj suglasnika je: " << sug << endl;
return 0;
}
The variables and texts are all in croatian. I know I could have made the suglasnici(consonants) variable as a string so it would be shorter but it's ok as long as it's working...