Completely Solved C, C++ Programs Assignment.




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

Filed Under:

Problem 83. C Program to read a string and print the first two characters of each word in the string.
#include<stdio.h>
#include<conio.h>
main( )
{
char s[100];
int i,l;
clrscr( );
printf(“enter a string”);
gets(s);l=strlen(s);
for(i=0;i<l;i++)
{
if(s[i]!=’ ‘ && s[i]=’ ‘)
{
printf(“%c %c”,s[i],s[i+1])
i=i+2;
while(s[i]!=’ ‘)
i++;
}
}
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