Advertisement
Bertran_rz

UpperCounter

Oct 26th, 2021
909
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4. using namespace std;
  5.  
  6. int UpperCount(char* str)
  7. {
  8.     int counter = 0;
  9.     for(int i = 0; str[i] != '\0'; i++)
  10.     {
  11.         if((int)str[i] > 64 && (int)str[i] < 91) counter++;
  12.     }
  13.  
  14.     return counter;
  15. }
  16.  
  17.  
  18. int main()
  19. {
  20.  
  21.     char* str = nullptr;
  22.  
  23.     char tmp[100];
  24.     cout << "Enter your text\n";
  25.     cin.getline(tmp,100);
  26.     str = new char[strlen(tmp)+1];
  27.     strcpy(str, tmp);
  28.    
  29.     cout << UpperCount(str) << endl;
  30.    
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement