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
  1. #include<stdio.h>
  2. #include<conio.h>
  3. main()
  4. {
  5. int i,alphabets=0,digits=0,symbols=0;
  6. char *s;
  7. clrscr();
  8. printf("Enter the string 1....");
  9. scanf("%s",s);
  10. for(i=0;s[i]!='\0';i++)
  11. {
  12. if(((s[i]>='A')&&(s[i]<='Z'))||((s[i]>='a')&&(s[i]<='z')))
  13. alphabets++;
  14. else if((s[i]>='0')&&(s[i]<='9'))
  15. digits++;
  16. else
  17. symbols++;
  18. }
  19. printf("\nAlphabets : %d",alphabets);
  20. printf("\nDigits : %d",digits);
  21. printf("\nSymbols : %d",symbols);
  22. getch();
  23. }
#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