Program Discussion :: Strings
347 / 60
WAP to Input a String either in C/JAVA .
Find all the Words Less than 3 Characters.
Example :
Input : Ram is a Boy
The Words Less than 3 Characters: is a
The Word Greater or equals to 4 characters: Ram and Boy
Answer:
#include
#include
int main()
{
int i,j,k=0,count=0,len;
char str[1000];
gets(str);
len = strlen(str);
for(i=0;i
Asked In ::
Language:
Ankit
1 Apr, 2019 10:15 PM
#include<stdio.h>
#include<string.h>
int main()
{
int i,j,k=0,count=0,len;
char str[1000];
gets(str);
len = strlen(str);
for(i=0;i<len;i++)
{
if(str[i]==' ')
{
j=i-1;
if(j-k<2)
{
while(k <= j)
{
printf("%c",str[k]);
k++;
}
printf("\n");
}
k = i+1;
}
if(i==len-1)
{
if(k-i<2)
while(k <= i)
{
printf("%c",str[k]);
k++;
}
}
}
return 0;
}