Learn C ProgrammingLearn ProgrammingPrograms On StringsResources

082. Write a program to accept a string and print no. of aphlabets, digits, special symbols present in it in C language

By September 18, 2012 September 5th, 2018 No Comments
#include<stdio.h>
#include<conio.h>  
#include<ctype.h>
main()
{
	char *s;
	int i,alphabets=0,digits=0,symbols=0;
	clrscr();
	printf("Enter string : ");
	scanf("%s",s);
	for(i=0;s[i]!='\0';i++)

		if(isalpha(s[i]))
			alphabets++;
		else if(isdigit(s[i]))
			digits++;
		else
			symbols++;

	printf("\nAphabets : %d",alphabets);
	printf("\nDigits   : %d",digits);
	printf("\nSymbols  : %d",symbols);
	getch();
}


Leave a Reply

DEMO01