Write A Program for counting the number of words in a given string

#include<stdio.h> #include<conio.h> void main ( ) { char a [ 50]; int i ,s=1, l; printf (“enter a string); get...

#include<stdio.h>
#include<conio.h>
void main ( )
{
char a [ 50];
int i ,s=1, l;
printf (“enter a string);
gets ( a);
l = strlen(a);
for ( i = 0, i < l; i ++)
{
if ((a[i] = = ‘ ')  && (a[i+1] ! = ' ') || a [i]= = ‘\0’)
s++;
}
printf (“number of words %d”, s);
getch ( );
}

Related

C Programs 7162732419182697217

Post a Comment

emo-but-icon

item