Answers for "program to count number of single character in a string in c"

C
1

count number of words in a string in c

/*
 * C Program to Count Number of Words in a given Text Or Sentence
 */
#include <stdio.h>
#include <string.h>
 
void main()
{
    char s[200];
    int count = 0, i;
 
    printf("Enter the string:n");
    scanf("%[^n]s", s);
    for (i = 0;s[i] != '';i++)
    {
        if (s[i] == ' ' && s[i+1] != ' ')
            count++;    
    }
    printf("Number of words in given string are: %dn", count + 1);
}
Posted by: Guest on June-21-2021
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 "program to count number of single character in a string in c"

Code answers related to "C"

Browse Popular Code Answers by Language