Completely Solved C, C++ Programs Assignment.




C Program to read a string and print the number of characters in each word of the string

Filed Under:

Problem 80. C Program to read a string and print the number of characters in each word of the string.
#include<stdio.h>
#include<conio.h>
#include<string.h>
main( )
{
char s[100];
int i,l,nc=0;
clrscr( );
printf(“enter the sting”);
gets(s);
l=strlen(s);
for(i=0;i<l;i++)
{
if(s[i]!=’ ‘)
{
nc=0;
while(s[i]!=’ ‘)
{
nc++;
printf(“%c”,s[i]);
i++;
if(s[i]=’�’)
break;
}
printf(“tt %d”,nc);
printf(“n”);
}
}
getch();
}

C compiler: gcc 4.1.2

 Back to main directory: Sample C Program | Software Practical | Solved C Assignment


Get Free Programming Tutorials and Solved assignments