In the above code, we have opened the file "names.dat" in read mode. And then read character by character from the file and check if its case, if it is uppercase then we have added one to upperCount variable that stores the count of uppercase characters. Then at the end, return the count of uppercase characters in the file.
Program to illustrate the solution of the problem
Contents of file: (names.dat)
Output:
In the above code, we have opened the file "names.dat" in read mode. And then read character by character from the file and check if its case, if it is uppercase then we have added one to upperCount variable that stores the count of uppercase characters. Then at the end, return the count of uppercase characters in the file.
need an explanation for this answer? contact us directly to get an explanation for this answer