fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. int main()
  5. {
  6. int t;
  7. cin>>t;
  8. while(t--)
  9. {
  10. //Using a string data type to store the input.
  11. string s;
  12. cin>>s;
  13. ll ans = 0;
  14. for(ll i =0;i < s.size(); i++)
  15. {
  16. //Using a counter that counts the capital alphabets in the given string based on their ASCII values.
  17. //The ASCII values of the capital alphabets start from a=65 to z=90.
  18. if(s[i]>=65 && s[i]<=90)
  19. {
  20. ans++;
  21. }
  22. }
  23. cout<<ans<<endl;
  24. }
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0s 4176KB
stdin
1
ThisIsCool
stdout
3