Learn C ProgrammingLearn ProgrammingPrograms On StringsResources

090. Write a program to count no, of alphlabets, digits, special symbols in C language

By September 18, 2012 September 5th, 2018 3 Comments

#include<stdio.h>
#include<conio.h>  
main()
{
	int i,alphabets=0,digits=0,symbols=0;
	char *s;
	clrscr();
	printf("Enter the string 1....");
	scanf("%s",s);

	for(i=0;s[i]!='\0';i++)
	{
		 if(((s[i]>='A')&&(s[i]<='Z'))||((s[i]>='a')&&(s[i]<='z')))
				alphabets++;
		 else if((s[i]>='0')&&(s[i]<='9'))
				digits++;
		 else
				symbols++;
	}
	printf("\nAlphabets : %d",alphabets);
	printf("\nDigits    : %d",digits);
	printf("\nSymbols   : %d",symbols);
	getch();
}

3 Comments

Leave a Reply

DEMO01