Answer to Question #318734 in C++ for Naqibullah

Question #318734

Write a program that takes character array as an input and count the number of capital character in it.

 

 


1
Expert's answer
2022-03-26T14:01:42-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog