Asked inPracto,

Character Counting Program

Develop a program to calculate and display the total number of specific characters: lowercase English alphabets, digits (0 to 9), and white spaces (including space, tab '\t', and newline '\n') in a given input stream that ends with the character '$'.

Explanation:

The input is a continuous stream of characters, and the program should process all characters until the termination character '$' is encountered.

Input:

A stream of characters terminated by '$'

Output:

3 integers i.e. count_of_characters count_of_digits count_of_whitespaces (separated by space)

Example:

Input:
hello 123	
world$
Output:
10 3 3

Constraints:

  • The input stream can contain any printable ASCII characters.
  • The termination character '$' is not counted.
Note:

Ensure that your program accurately counts the specified character types and outputs them in the correct order.

Be the first one to answer
Add answer anonymously...
Practo Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter