Write a program, enter a line of characters, and press enter to finish counting the numbers of English letters, spaces, numbers, and other characters.

Source: Internet
Author: User
# Include <stdio. h> int main () {int letter = 0, Space = 0, digit = 0, others = 0; // declare English letters, spaces, the Count variable of the number and other characters is initialized to 0 char C; // declare the variable while (C = getchar () that receives the string ())! = '\ N') {// If (C = '') of the judgment mark ending with a carriage return. // space ++ is detected; else if (C> = '0' & C <= '9') // The number digit ++ is detected; else if (C> = 'A' & C <= 'Z') | (C> = 'A' & C <= 'Z ')) // The letter is detected, and the uppercase and lowercase letter ++; else others ++;} // output result printf ("the number of letters is: % d \ n ", letter); printf (" the number of spaces is: % d \ n ", space); printf (" the number of digits is: % d \ n ", digit); printf (" the number of other words is: % d \ n ", others); Return 0 ;}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.