Outputs the number of letters, numbers, and special characters, based on the input string, respectively

Source: Internet
Author: User

#include"stdio.h"voidMain () {//definition string, I receive string variable j loop condition variable z Total number of S number F symbol total     Chari[ -]; intj,z=0, s=0, f=0; printf ("Please enter a string:"); scanf ("%s",&i);  for(j=0; J<=strlen (i); j + +)//strlen (i) calculates the total length of characters typed, compared with J as a cyclic condition{printf ("%c", I[j]); if(i[j]>='a'&&i[j]<='Z'|| i[j]>='A'&&i[j]<='Z')//determine the number of the letter condition ASCLL table corresponding to{z++; }            Else if(i[j]>='0'&&i[j]<='9')//judging the numerical conditions{s++; }Else 

if((i[j]>='!'&&i[j]<='/')|| (i[j]>=':'&&i[j]<='@')|| (i[j]>= the&&i[j]<= the)|| (i[j]>='{'&&i[j]<='~')) //determine the number of special symbol conditions ASCLL table corresponding{f++; }} printf ("\ n Letter:%d\n", z);//Output Calculation Resultsprintf"numbers:%d\n", s); printf ("symbol:%d\n", F); }

Outputs the number of letters, numbers, and special characters, based on the input string, respectively

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.