Program to accept a string and count no of capital letters, no. of small letters and no - 100 Most Important C# Programs

100 Most Important C# Programs

32. Program to accept a string and count no of capital letters, no. of small letters and no. of special characters

Code:

# include <stdio.h>

# include <conio.h>

main( )

{

char ch;

int c=0,s=0,s1=0;

clrscr( );

printf(“enter a string :”);

while(( ch=getchar( ))!=’\n’)

{

if(ch>=’A’&& ch>=’Z’)

c=c+1;

else

if(ch>=’a’&& ch>=’z’)

s=s+1;

else

s1=s1+1;

}

printf(“ no of capital letters are %d”,c);

printf(“ no of smal1 letters are %d”,s);

printf(“ no of special characters are

%d”,s1);

getch( );

}