Answers for "c program to count number of characters in a string using function"

C
0

find character from string c count

#include <stdio.h>
#include <string.h>
 
int main()
{
    char s[1000],c;  
    int i,count=0;
 
    printf("Enter  the string : ");
    gets(s);
    printf("Enter character to be searched: ");
    c=getchar();
    
    for(i=0;s[i];i++)  
    {
    	if(s[i]==c)
    	{
          count++;
		}
 	}
     
	printf("character '%c' occurs %d times n ",c,count);
 
 	 
     
    return 0;
}
Posted by: Guest on December-02-2020
0

program in C to count total number of alphabets, digits and special characters in a string.

Count total number of alphabets, digits and special characters :                                              
--------------------------------------------------------------------                                          
Input the string : Welcome to w3resource.com                                                                  
Number of Alphabets in the string is : 21                                                                     
Number of Digits in the string is : 1                                                                         
Number of Special characters in the string is : 4
Posted by: Guest on September-08-2021

Code answers related to "c program to count number of characters in a string using function"

Code answers related to "C"

Browse Popular Code Answers by Language