#include <cstdlib>
#include <iostream>
#include <cstring>
using namespace std;
int vocals_per_100(char s[]);
int main(int argc, char *argv[])
{
char string[255];
cout<<"Insert the string"<<endl;
cin>>string;
cout<<vocals_per_100(string);
system("PAUSE");
return EXIT_SUCCESS;
}
int vocals_per_100(char s[]){
int c=0;
int l=strlen(s);
char w[255];
strupr(w);
for(int i=0;i<l;i++)
if(w[i]=='A'||w[i]=='E'||w[i]=='I'||w[i]=='O'||w[i]=='U')
c++;
return c;
}
This code should calculate the percentage of vocals in a string
If I push F9 it runs correctly,it asks me to insert the string but the result
of the function is always 0 ...
Is there someone who can help me ?
Thanks !
*** MOD EDIT: Added code tags. Please
This post has been edited by JackOfAllTrades: 17 November 2009 - 12:18 PM

New Topic/Question
Reply




MultiQuote





|