9.4.20

finding number of word in a sentence example 1


FINDING NUMBER OF WORDS IN A SENTENCE EXAMPLE 1
#include <stdio.h>
int main()
{
    char st[128];
    int i,nwords=0;
    puts("enter a sentence");
    gets(st);
    for(i=0;st[i]!=0;i++)
         if(st[i]=='')
        nwords++;
    printf("numbers of words=%d",nwords+1);
return 0;
}
OUTPUT
Enter a sentence
Incredible india
Number of words =2


No comments:

Post a Comment

JAVA program pattern 2

import java.util.Scanner; public class pattern3 { public static void main(String args[]) { int i,j; Scanner sc=new Scanner(System.in); Syste...