In: Computer Science
Write a C++ program to read characters from the keyboard until a '#' character is read. Then the program will find and print the number of uppercase letters read from the keyboard.
CODE:
#include <iostream>
using namespace std;
//main function
int main()
{
char ch;
//count variable to keep count of upper case letters
int count=0;
cout<<"Start typing the input string"<<endl;
//while loop for taking input string
while(true)
{
cin.get(ch);
//if input character is # break
if(ch=='#')break;
//if input character is upper case increment the count
if(ch>=65&&ch<=90)count++;
}
//printing the count of upper case letters
cout<<count<<endl;
}
SAMPLE OUTPUT:
NOTE: If you got any sort of help from this article please UPVOTE and in case of any query please do mention in comments...