#include < stdio.h >
void main()
{
char a[50],ch;
int i,j;
do
{
clrscr();
j=1;
printf("Counting no of words in a given string\n\n");
printf("Enter a string : ");
gets(a);
for(i=0;a[i]!='\0';i++)
{
if(a[i]==' ')
j+=1;
}
printf("Total no of words : %d",j);
printf("\n\n\nDo you want to continue (y/n?) : ");
ch=getch();
}while(ch=='y'||ch=='Y');
}
void main()
{
char a[50],ch;
int i,j;
do
{
clrscr();
j=1;
printf("Counting no of words in a given string\n\n");
printf("Enter a string : ");
gets(a);
for(i=0;a[i]!='\0';i++)
{
if(a[i]==' ')
j+=1;
}
printf("Total no of words : %d",j);
printf("\n\n\nDo you want to continue (y/n?) : ");
ch=getch();
}while(ch=='y'||ch=='Y');
}
No comments:
Post a Comment