any c++ programmers need help pleaseeeeeee
its not compiling can someone please please fix it
It compiles just fine for me...
test run: Enter a string: hello Total count of letters(s) is 5 with 0 upper case letter(s) 5 lower case letter(s) 2 vowels(s) 3 consonants(s) The reverse string : olleh
it didnt work into my visual studio D:
are you on a mac or pc?
pc
do you have MinGW?
no
i see some red lines
if you install it and its c++ compiler from the command line you can do: g++ part_1.cpp and it should compile just fine. I can't help you with visual studio... I am on a mac to mine compiles to a.out.... yours will compile to a.exe
oh
There is nothing wrong with those code.... maybe the compiler in your version of visual studio does not like it...
hmmm
try an online compiler then :)
Go here: http://cpp.sh/5mxf6 ...and then click run to see your code does work.
#include <string> #include <iostream> using namespace std; bool isPunctuation(char c); //function to check punctuation character bool isVowel(char c); //function to check character is vowel or not string reverseString(string i); //function reverses a string //Additional functions below bool isDigit(char c); //function check whether digit or not bool isWhiteSpace(char c); //function check whitespace bool isUpperCase(char c); //function checks upper case bool isLowerCase(char c); //function checks lower case int main() { //code here int letters,ucase=0,lcase=0,vowels=0,digits=0,spaces=0,others=0,pcount=0; string st; cout<<"\nEnter a string: "; getline(cin,st);//input complete string here if(st.empty()) { cout<<"\nNo string was entered"; return 1; } for(unsigned int i=0;i<st.length();i++) //repeat up to string length { //calling each function and checking true or false //and increment respective count variables if(isLowerCase(st[i])) lcase++; else if(isUpperCase(st[i])) ucase++; if(isVowel(st[i])) vowels++; else if(isPunctuation(st[i])) pcount++; else if(isWhiteSpace(st[i])) spaces++; else if(isDigit(st[i])) digits++; else if(!isLowerCase(st[i]) && !isUpperCase(st[i])) others++; } //printing of all statistics by calling functions defined letters=(lcase+ucase); //check the condition if alphabetical letters are found if(letters>0) { cout<<"\nTotal count of letters(s) is "<<letters<<" with"<<endl; cout<<"\t"<<ucase<<" upper case letter(s)"<<endl; cout<<"\t"<<lcase<<" lower case letter(s)"<<endl; cout<<"\t"<<vowels<<" vowels(s)"<<endl; cout<<"\t"<<(letters-vowels)<<" consonants(s)"<<endl; } //Check conditions for other special characters and digits and punctuations //then print each if(digits>0) cout<<"\nTotal count of digits(s) is "<<digits<<endl; if(pcount>0) cout<<"\nTotal count of punctuation mark(s) is "<<pcount<<endl; if(spaces>0) cout<<"\nTotal count of whitespace(s) is "<<spaces<<endl; if(others>0) cout<<"\nTotal count of other symbol charaters(s) is "<<others<<endl; cout<<"\nThe reverse string : "<< reverseString(st)<<endl; return 0; } //function to check punctuation character bool isPunctuation(char c) { if(c==',' || c=='.' || c=='?' || c==';' || c==':' || c=='\"' || c=='\'' || c=='{' || c=='}' || c=='[' || c==']' || c=='/' || c=='!' || c=='-' ) return true; else return false; } //function to check character is vowel or not bool isVowel(char c) { if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u' || c=='A' || c=='E' || c=='I' || c=='O' || c=='U') return true; else return false; } //function reverses a string string reverseString(string i) { string rev=""; //empty string declare for(int j=i.length()-1;j>=0;j--) rev+=i[j]; return rev; } //Additional functions below //function check whether digit or not bool isDigit(char c) { if(c>='0' && c<='9') return true; else return false; } //function check whitespace bool isWhiteSpace(char c) { return c==' '; } //function checks upper case bool isUpperCase(char c) { if(c>='A' && c<='Z') return true; else return false; } //function checks lower case bool isLowerCase(char c) { if(c>='a' && c<='z') return true; else return false; }
yes but the black window as the output closes automatically
@marcelie bang ur pc against the wall
lool yall help me out... idk why the output isnt working
workng for me .... u can see the output
yes it works there haha but on vs it doesnt work
im gettin frrustrated arghh lol
Do you need to turn in a compiled file or what do you need to get credit?
well it compiles but the blakc window closes by itself :/
ohhhhh i see your problem
yes so what do i do ? D:
run your program from inside the terminal... it is closing before you can see the result
it is a windows thing
yeah so what do i do
ok go to the folder where your .exe file is and shift+right click in the folder
then click open command prompt here
then type <yourfile>.exe
any luck?
i dont see it lol
ok do this instead... if you hit "win+r" do you get the run box?
yes you mean the black box ?
No. "Win+R" should open the run dialog.
Then you need to type "cmd" and press enter
Then navigate to your file and run it from inside the terminal.
nvm got it .. ty all
#include <string> #include <iostream> #include <iomanip> using namespace std; bool isPunctuation(char c); //function to check punctuation character bool isVowel(char c); //function to check character is vowel or not string reverseString(string i); //function reverses a string //Additional functions below bool isDigit(char c); //function check whether digit or not bool isWhiteSpace(char c); //function check whitespace bool isUpperCase(char c); //function checks upper case bool isLowerCase(char c); //function checks lower case int main() { //code here int letters, ucase = 0, lcase = 0, vowels = 0, digits = 0, spaces = 0, others = 0, pcount = 0; string st; cout << "Enter a string: "; getline(cin, st);//input complete string here if (st.empty()) { cout << "\nNo string was entered."; getchar(); return 1; } for (unsigned int i = 0; i<st.length(); i++) //repeat up to string length { //calling each function and checking true or false //and increment respective count variables if (isLowerCase(st[i])) lcase++; else if (isUpperCase(st[i])) ucase++; if (isVowel(st[i])) vowels++; else if (isPunctuation(st[i])) pcount++; else if (isWhiteSpace(st[i])) spaces++; else if (isDigit(st[i])) digits++; else if (!isLowerCase(st[i]) && !isUpperCase(st[i])) others++; } //printing of all statistics by calling functions defined letters = (lcase + ucase); //check the condition if alphabetical letters are found if (letters>0) { cout << "\nTotal count of letters(s) is " << letters << " with" << endl; cout << setw(11) << ucase << " upper case letter(s)" << endl; cout << setw(11) << lcase << " lower case letter(s)" << endl; cout << setw(11) << vowels << " vowels(s)" << endl; cout << setw(11) << (letters - vowels) << " consonants(s)" << endl; } //Check conditions for other special characters and digits and punctuations //then print each if (digits>0) cout << "\nTotal count of digits(s) is " << digits << endl; if (pcount>0) cout << "\nTotal count of punctuation mark(s) is " << pcount << endl; if (spaces>0) cout << "\nTotal count of whitespace(s) is " << spaces << endl; if (others>0) cout << "\nTotal count of other symbol charaters(s) is " << others << endl; cout << "\nThe reverse string : " << reverseString(st) << endl; getchar(); return 0; } //function to check punctuation character bool isPunctuation(char c) { if (c == ',' || c == '.' || c == '?' || c == ';' || c == ':' || c == '\"' || c == '\'' || c == '{' || c == '}' || c == '[' || c == ']' || c == '/' || c == '!' || c == '-' || c == '(' || c == ')') return true; else return false; } //function to check character is vowel or not bool isVowel(char c) { if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U') return true; else return false; } //function reverses a string string reverseString(string i) { string rev = ""; //empty string declare for (int j = i.length() - 1; j >= 0; j--) rev += i[j]; return rev; } //Additional functions below //function check whether digit or not bool isDigit(char c) { if (c >= '0' && c <= '9') return true; else return false; } //function check whitespace bool isWhiteSpace(char c) { return c == ' '; } //function checks upper case bool isUpperCase(char c) { if (c >= 'A' && c <= 'Z') return true; else return false; } //function checks lower case bool isLowerCase(char c) { if (c >= 'a' && c <= 'z') return true; else return false; }
Join our real-time social learning platform and learn together with your friends!