Write a program that takes character array as an input and count the number of capital character in it.
#include <iostream>
#include <cctype>
using namespace std;
int coutnUppercase(char arr[]) {
int count = 0;
int i=0;
while (arr[i]) {
if (isupper(arr[i])) {
count++;
}
i++;
}
return count;
}
int main() {
const int SIZE=1024;
char buf[SIZE];
cout << "Enter charcters: ";
cin.getline(buf, SIZE);
int count = coutnUppercase(buf);
cout << "There are " << count << " capital letters in a string" << endl;
return 0;
}
Comments
Leave a comment