fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. char response;
  5. string s;
  6. int upper, lower, other, count;
  7. void capCheck(string);
  8. int main()
  9. {
  10. count = 0;
  11. upper = 0;
  12. lower = 0;
  13. do
  14. {
  15. cout<<"Get the number of upper and lower case letters in your sentence!!"<<endl;
  16. cout<<endl;
  17. cout<<"Type your sentence below without spaces.."<<endl;
  18. cin>>s;
  19. capCheck(s);
  20. cout<<"Would you like to continue? Y/N"<<endl;
  21. cin>>response;
  22. }while(response == 'y' || response == 'Y');
  23. return 0;
  24. }
  25. void capCheck(std::string s)
  26. {
  27. while(s[count] != 0)
  28. {
  29. if(s[count] >= 'a' && s[count] <= 'z')
  30. {
  31. lower++;
  32. count++;
  33. }
  34. else if (s[count] >= 'A' && s[count] <= 'Z')
  35. {
  36. upper++;
  37. count++;
  38. }
  39. else
  40. other++;
  41. }
  42. cout<<"The number of uppercase letters are: "<<upper<<endl;
  43. cout<<"The number of lowercase letters are: "<<lower<<endl;
  44. }
Success #stdin #stdout 0s 3304KB
stdin
Standard input is empty
stdout
Get the number of upper and lower case letters in your sentence!!

Type your sentence below without spaces..
The number of uppercase letters are: 0
The number of lowercase letters are: 0
Would you like to continue? Y/N