Input a sentence and print the number of word in it.
#include <stdio.h>
#include <conio.h>
void main ( )
{
char nm[80];
int i, ln, co = 0;
clrscr ( );
printf("\n\n\n\t\t Enter a sentence....:"); gets (nm);
for ( ln = 0; nm[ln] != '\0'; ln++ );
for ( i = 0; i < ln; i++ )
{
if ( nm[i] == ' ' )
{
co++;
}
}
printf("\n\n\n\t\t Number of sentence...: %d ", co + 1);
getch ( );
}
Click here to contact us
#include <stdio.h>
#include <conio.h>
void main ( )
{
char nm[80];
int i, ln, co = 0;
clrscr ( );
printf("\n\n\n\t\t Enter a sentence....:"); gets (nm);
for ( ln = 0; nm[ln] != '\0'; ln++ );
for ( i = 0; i < ln; i++ )
{
if ( nm[i] == ' ' )
{
co++;
}
}
printf("\n\n\n\t\t Number of sentence...: %d ", co + 1);
getch ( );
}
No comments:
Post a Comment