Sunday, 22 October 2017

Count Word of a String

#include<stdio.h>
int main()
{
    char a[50];
    int l,word=0,i=0;
    printf("Enter A String: ");
    gets(a);
    for(l=0;a[l]!='\0';l++);
    for(i=0;i<=l;i++)
    {
        if(a[i]==' ' && a[i+1]!=' ')
            word++;
    }
    printf("%d",word+1);
    return 0;


}

No comments:

Post a Comment

Featured Post

TCS Latest Test Patern ( For On-Campus Drives )

Tata Consultancy Services is software services consulting company whose  headquarter is situated in Mumbai, India. It is the Asia’s larges...